wiseman / foursquare-python
- Source
- Commits
- Network (2)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Fri Nov 27 10:32:04 -0800 2009 | |
| |
LICENSE.txt | Thu Nov 26 12:52:20 -0800 2009 | |
| |
README.rst | Thu Dec 17 21:08:23 -0800 2009 | |
| |
foursquare.py | Tue Jan 26 08:02:03 -0800 2010 | |
| |
tests/ | Tue Dec 08 04:04:17 -0800 2009 |
README.rst
Copyright 2009 John Wiseman
Covered by the MIT License, see LICENSE.txt.
foursquare
This Python module lets you access the foursquare API. It supports unauthenticated access, basic HTTP authentication, and OAuth authorization.
It supports all the v1 foursquare API methods as of 2009-12-17.
This module requires Leah Culver's oauth module, oauth.py.
API method names are the same in Python, except for methods like "friend/requests", which are translated to names like "friend_requests" in Python.
All arguments are keyword arguments, though required arguments come first and are in the order listed by the API documentation.
All methods return the Python equivalent of the JSON response returned by the corresponding API method, if there is a response.
Examples
No authentication:
>>> import foursquare
>>> fs = foursquare.Foursquare()
>>> fs.cities()
{'cities': [{'geolat': 52.378900000000002, 'name': 'Amsterdam', ...}]}
Basic HTTP authentication:
>>> import foursquare
>>> fs = foursquare.Foursquare(foursquare.BasicCredentials(username, password))
>>> fs.switchcity(23)
{'data': {'status': '1', 'message': 'City switched successfully'}}
>>> fs.switchcity(34)
{'data': {'status': '1', 'message': 'City switched successfully'}}
>>> fs.user()
{'user': {'city': {'geolat': 34.0443, 'name': 'Los Angeles', ...}}}
OAuth:
>>> import foursquare
>>> credentials = foursquare.OAuthCredentials(oauth_key, oauth_secret)
>>> fs = foursquare.Foursquare(credentials)
>>> app_token = fs.request_token()
>>> auth_url = fs.authorize(app_token)
>>> # Go to auth_url and authorize, then continue.
>>> user_token = fs.access_token(app_token)
>>> credentials.set_access_token(user_token)
>>> fs.user()
{'user': {'city': {'geolat': 34.0443, 'name': 'Los Angeles', ...}}}
