Skip to content

Latest commit

 

History

History
148 lines (130 loc) · 4.01 KB

api.md

File metadata and controls

148 lines (130 loc) · 4.01 KB

Api documentation

For clarification when I talk about 'posts' or a 'post object' I do not mean a 'post' as in get/post request. But a post is just an uploaded image or video.

Posts

Get requests

Example Call: https://pr0gramm.com/api/items/get?promoted=1&older=2000
This will return all posts which are older than the post 2000 and have been in top.

promoted

Setting protmoted=1 in the api get request will get you all posts which have been in top. Promoted is also an attribute of the returned post. Here it is the number of the post in top, so for example promoted=3000 will mean that this is the three thousandth post in top.

older/ newer

In order to specify which posts you want you can user older and newer. For example https://pr0gramm.com/api/items/get?older=25000 will get you the posts older than the post 25000. If you don't specify wether you want newer or older posts: for example https://pr0gramm.com/api/items/get?id=2500000 you will get the post 2500000 and the the newer ones.

Example response:

https://pr0gramm.com/api/items/get?id=2525097&flags=9

{
  "atEnd": false,
  "atStart": false,
  "error": null,
  "items": [
    {
      "id": 2525097,
      "promoted": 0,
      "up": 197,
      "down": 62,
      "created": 1524733667,
      "deleted": 0,
      "image": "2018\\/04\\/26\\/c6b285ecd87367cb.jpg",
      "thumb": "2018\\/04\\/26\\/c6b285ecd87367cb.jpg",
      "fullsize": "2018\\/04\\/26\\/c6b285ecd87367cb.png",
      "width": 1052,
      "height": 658,
      "audio": false,
      "source": "",
      "flags": 1,
      "user": "itssme",
      "mark": 0
    },
    .
    .
    .
    ],
  "ts": 1526741044,
  "cache": "stream:new:9:id2525097",
  "rt": 6,
  "qc": 3
}

  • atEnd:bool
    Will be true if the requested object is the first one

  • atStart:bool
    Will be true if the requested object is the newest one

  • error:str
    Will contain a message if a faulty request is made
    For example if requesting an item that does not exist error will be: "error"="notFound" and items will look like "items"=null

  • item:list
    A list containing posts
    • post:dict
      • id:int
        unique id of the post
      • promoted:int
        Will be the number of the post in top. For example the post with the id 2559630 is the 325927 post which was in top.
      • up:int
        Number of upvotes
      • down:int
        Number of downvotes
      • created:int
        A timestamp fot the creation of the post
      • deleted:int
        Default value is 0
        Will be set to 1 if the post is deleted
      • image:str
        Image address for https://img.pr0gramm.com/
        For example: https://img.pr0gramm.com/2018/05/19/12140f2ac817985f.jpg
      • thumb:str
        Thumbnail for a post
      • fullsize:str
        Only for high quality images which are not getting displayed by default.
        For example: https://pr0gramm.com/top/2558778 to get the image in full quality click the "+": https://full.pr0gramm.com/2018/05/18/a4e8e4ceb473b03a.jpg
      • width:int
        Width of the image or video
      • height:int
        Height of the image or video
      • audio:bool
        True if the video contains audio
      • source:str
        A link if the image/video was directly uploaded from another website otherwise an emtpy string
      • flags:int
        Flags for sfw/nsfp/nsfw/nsfl/pol
      • user:str
        Unique name of the uploader

  • mark:int

  • ts:int

  • rt:int

  • qc:int

Post Object

todo

Getting comments and tags for a post

todo

Getting info about users

todo

Login for NSFW/NSFP/NSFL

todo

Examples

from pr0gramm import *
api = Api("gamb", "adminadmin", "/tmp")
if api.login():
    print("logged in")
else:
    print("failed to log in")