{ "info": { "author": "Jonathan Paugh", "author_email": "jpaugh@gmx.us", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 3", "Topic :: Utilities" ], "description": "# The Agnostic GitHub API\n\n> It doesn't know, and you don't care!\n\n`agithub` is a REST API client with transparent syntax which facilitates\nrapid prototyping — on *any* REST API!\n\nOriginally tailored to the GitHub REST API, AGitHub has grown up to\nsupport many other REST APIs:\n\n* DigitalOcean\n* Facebook\n* GitHub\n* OpenWeatherMap\n* SalesForce\n\nAdditionally, you can add *full support* for another REST API with very\nlittle new code! To see how, check out the [Facebook client], which has\nabout 30 lines of code.\n\nThis works because AGithub knows everything it needs to about protocol\n(REST, HTTP, TCP), but assumes nothing about your upstream API.\n\n[Facebook client]: agithub/Facebook.py\n\n# Use\n\nThe most striking quality of AGitHub is how closely its syntax emulates\nHTTP. In fact, you might find it even more convenient than HTTP, and\nalmost as general (as far as REST APIs go, anyway). The examples below\ntend to use the GitHub API as a reference point, but it is no less easy to\nuse `agithub` with, say, the Facebook Graph.\n\n## Create a client\n\n```python\nfrom agithub.GitHub import GitHub\nclient = GitHub()\n```\n\n## GET\n\nHere's how to do a `GET` request, with properly-encoded url parameters:\n\n```python\nclient.issues.get(filter='subscribed')\n```\n\nThat is equivalent to the following:\n\n```http\nGET /issues/?filter=subscribed\n```\n\n## POST\n\nHere's how to send a request body along with your request:\n\n```python\nsome_object = {'foo': 'bar'}\nclient.video.upload.post(body=some_object, tags=\"social devcon\")\n```\n\nThis will send the following request, with `some_object` serialized as\nthe request body:*\n\n```http\nPOST /video/upload?tags=social+devcon\n\n{\"foo\": \"bar\"}\n```\n\nThe `body` parameter is reserved and is used to define the request body to be\nPOSTed. `tags` is an example query parameter, showing that you can pass both\nan object to send as the request body as well as query parameters.\n\n* For now, the request body is limited to JSON data; but\nwe plan to add support for other types as well\n\n## Parameters\n\n### `headers`\n\nPass custom http headers in your ruquest with the reserved parameter `headers`.\n\n```python\nfrom agithub.GitHub import GitHub\ng = GitHub()\nheaders = {'Accept': 'application/vnd.github.symmetra-preview+json'}\nstatus, data = g.search.labels.get(headers=headers, repository_id=401025, q='\u00af\\_(\u30c4)_/\u00af')\nprint(data['items'][0])\n```\n\n```text\n{u'default': False, u'name': u'\\xaf\\\\_(\\u30c4)_/\\xaf', u'url': u'https://api.github.com/repos/github/hub/labels/%C2%AF%5C_(%E3%83%84)_/%C2%AF', u'color': u'008672', u'node_id': u'MDU6TGFiZWwxMTcwNjYzNTM=', u'score': 43.937515, u'id': 117066353, u'description': u''}\n\n```\n\n### `body`\n\nIf you're using `POST`, `PUT`, or `PATCH` (`post()`, `put()`, or `patch()`), \nthen you should include the body as the `body=` argument. The body is \nserialized to JSON before sending it out on the wire.\n\n```python\nfrom agithub.GitHub import GitHub\ng = GitHub()\n# This Content-Type header is only required in this example due to a GitHub \n# requirement for this specific markdown.raw API endpoint\nheaders={'Content-Type': 'text/plain'} \nbody = '# This should be my header'\nstatus, data = g.markdown.raw.post(body=body, headers=headers)\nprint(data)\n```\n\n```text\n