Skip to content

scohen2002/APISamples

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

APISamples

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:

http://api.ap.org/v2/search/{mediatype}?apikey={apikey}&q={searchterms}

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:

http://api.ap.org/v2/search/photo?apikey=your_api_key&q=computer

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})

About

A compilation of sample code that uses the APIs provided by the Associated Press

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Perl 24.2%
  • PHP 18.7%
  • PowerShell 17.5%
  • C# 14.8%
  • JavaScript 13.9%
  • Python 10.9%