A compilation of sample code that uses the APIs provided by the Associated Press
JavaScript C++ CSS Perl Ruby PHP Other
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
APContentAPI C++ update Mar 26, 2014
LICENSE Added Adobe Flex Sample Mar 21, 2014
README.md Added Adobe Flex Sample Mar 21, 2014



This is a repository of code samples for the Associated Press APIs.

You will need to sign up for an API key before you can use any of the code in this repository.

#AP Content API

The full developer's guide can be found here.

##Basic Search

Basic search can be achieved using the following HTTP GET call:


mediatype can be photo, video, or graphic depending on the media type you are looking for. apikey is your API key and q is your search terms. As an example:


This returns photos about the search term "computer."

###Payload Format Support

The API returns XML (Atom 1.0) by default, but it can return JSON by applying accept:application/json in the header and JSONP by passing a callback HTTP GET parameter. Here is an example snippet in Python requesting for a JSON payload:

import requests

apikey = 'my_api_key'
keyword_search = 'star wars'

payload = requests.get('http://api.ap.org/v2/search/photo',
                       headers={'accept': 'application/json'},
                       params={'apikey': apikey, 'q': keyword_search})