FANDOM


Apiclient.py is a simple Python API client script that makes it easy to invoke Resighting API methods from the command line. While it is perfectly possible to use curl for this, apiclient.py adds a simple layer of abstraction and documentation on top, so for example you don't need to remember all the urls. It can be downloaded from our public Resighting Utils GitHub repository https://github.com/mdneale/resighting-utils.

Apiclient.py requires Python 2.7.

ExamplesEdit

The script itself documents just about everything you need to know and apiclient.py --help provides a lot of information, but to get you started here are a few examples of API calls with the script.

Get details of the current user (the owner of the Access Token) by calling the User API method:

$ ./apiclient.py https://resighting-api.appspot.com User --access_token=ACCESS_TOKEN

Get an upload url to upload an image to by calling the UploadUrl API method:

$ ./apiclient.py https://resighting-api.appspot.com UploadUrl --access_token=ACCESS_TOKEN

Upload an image using the url returned from the previous method using the Upload API method:

$ ./apiclient.py https://resighting-api.appspot.com Upload --access_token=ACCESS_TOKEN --upload_url=UPLOAD_URL --filename=FILENAME

Create a new Sighting using for evidence the image just uploaded by calling the CreateSighting API method:

$ ./apiclient.py https://resighting-api.appspot.com CreateSighting --access_token=ACCESS_TOKEN --description="Test Sighting" --latitude=48.8396 --longitude=2.3014 --tz_offset=120 --blobtracker_id=BLOBTRACKER_ID

UsageEdit

Usage: apiclient.py server_url method [options]

Arguments:
  server_url            The url of the server where the API is running,
                        e.g. https://resighting-api.appspot.com
  method                The name of the API to invoke. See list below.

Methods:
  CreateLocatorSighting
  CreateSighting
  GetDailySighting
  GetSighting
  GetUser
  GetUserStatistics
  ListLocators
  ListLocatorSightings
  ListResightings
  ListSightingLocators
  ListSightings
  ListUserCountryStatistics
  ListUserLocators
  ListUserSightings
  Meta
  RemoveLocatorSighting
  ResightSighting
  UpdateSighting
  Upload
  UploadUrl
  User

Options:
  -h, --help            show this help message and exit
  --access_token=ACCESS_TOKEN
                        An API access token
  --accuracy=ACCURACY   The accuracy of a latitude and longitude in metres
  --altitude=ALTITUDE   An altitude in metres
  --altitude_accuracy=ALTITUDE_ACCURACY
                        The accuracy of an altitude reading in metres
  --blobtracker_id=BLOBTRACKER_ID
                        A blobtracker_id returned by the Upload API
  --cursor=CURSOR       A cursor returned by a previous call to the method
                        marking the point where listing should continue from.
  --date=DATE           A date in the format YYYY-MM-DD
  --description=DESCRIPTION
                        A description
  --fetch_size=FETCH_SIZE
                        The number of results to retrieve
  --filename=FILENAME   A file to upload
  --heading=HEADING     A heading
  --hold                Place a Sighting on hold
  --latitude=LATITUDE   A latitude
  --list_type=LIST_TYPE
                        The type of list to request: latest or nearest
                        Sightings
  --locator_id=LOCATOR_ID
                        A Locator id. Multiple can be specified.
  --longitude=LONGITUDE
                        A longitude
  --no-hold             Do not place a Sighting on hold
  --no-publish-to-facebook
                        Do not publish a Sighting to the user's Facebook wall
  --no-tweet-sighting   Do not tweet a Sighting
  --options             Send an OPTIONS HTTP request to the server
  --publish_to_facebook
                        Publish a Sighting to the user's Facebook wall
  --sandbox             Invoke the API in sandbox mode
  --sighting_id=SIGHTING_ID
                        A Sighting id
  --speed=SPEED         A speed
  --tweet_sighting      Tweet a Sighting
  --tz_offset=TZ_OFFSET
                        The number of minutes that the user's timezone is
                        offset from UTC. Valid values are from -720
                        (UTC-12:00) to 840 (UTC+14:00).
  --upload_url=UPLOAD_URL
                        The url to upload the file to
  --user_id=USER_ID     A user's id

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.