API
METHODS
REFERENCES
The Content Services API is RESTful. We use HTTP response codes to indicate API errors, and also use HTTP verbs which can be understood by off-the-shelf HTTP clients. JSON will be the default returned in all responses where the format is not specified, including errors.
The supported formats are JSON, JSONP, and XML.
https://tools.cdc.gov/api
The API returns the result of ALL requests using the same data structure.
All DateTime
fields are in the ISO 8601 format: yyyy-MM-ddTHH:mm:ssZ
{
"meta": {
"status": 200,
"message": [
{
"type": "Error",
"code": "",
"id": "",
"userMessage": "",
"developerMessage": ""
}
],
"resultSet": {
"id": "becbbe39-7308-422d-a567-690d588c4600"
},
"pagination": {
"total": 94,
"count": 20,
"max": 20,
"offset": 20,
"pageNum": 1,
"totalPages": 5,
"sort": "datePublished DESC, name ASC",
"currentUrl": "https://tools.cdc.gov/api/v2/resources/media?mediatype=html&max=20&offset=20&pagenum=3",
"previousUrl": null,
"nextUrl": null
}
},
"results": [
{...},
{...}
]
}
Represents all the multi-media types (HTML, Images, Buttons, Badges, Widgets, Infographics, etc.) in the Content Services System.
{
"id": 16,
"name": "Tobacco Use - Winnable Battles",
"description": null,
"mediaType": "HTML",
"language": {
"name": "English",
"isoCode": "eng"
},
"tags": [
{
"id": 10,
"name": "Smoking Cessation",
"language": "English",
"type": "Topic"
}
],
"geoTags": [
{
"name": "Bleckley County",
"countryCode": "US",
"geoNameId": 4183415,
"parentId": 4197000,
"latitude": 32.43444,
"longitude": -83.32784,
"timezone": "America/New_York",
"admin1Code": "GA"
}
],
"campaigns": [],
"source": {
"name": "Centers for Disease Control and Prevention",
"acronym": "CDC",
"websiteUrl": null,
"largeLogoUrl": null,
"smallLogoUrl": null
},
"attribution": null,
"domainName": "http://www.fda.gov/",
"owningOrgName": null,
"owningOrgId": null,
"maintainingOrgName": null,
"maintainingOrgId": null,
"sourceUrl": "http://www.cdc.gov/winnablebattles/Tobacco/index.html",
"targetUrl": "http://www.cdc.gov/winnablebattles/Tobacco/index.html",
"persistentUrl": null,
"thumbnailUrl": "https://tools.cdc.gov/api/v2/resources/media/16/thumbnail",
"alternateImages": [
{
"id": 4,
"name": "Facebook",
"width": 155,
"height": 84,
"url": "https://tools.cdc.gov/api/v2/resources/links/4.png"
},
{...}
],
"alternateText": null,
"noScriptText": null,
"featuredText": null,
"embedCode": null,
"author": null,
"length": "",
"size": null,
"height": null,
"width": null,
"childCount": 0,
"children": [],
"parentCount": 0,
"parents": [],
"rating": null,
"ratingCount": null,
"ratingCommentCount": null,
"status": "Published",
"datePublished": "2014-03-18T20:30:00Z",
"dateModified": "2013-04-01 12:00:00",
"dateContentAuthored": null,
"dateContentUpdated": null,
"dateContentPublished": null,
"dateContentReviewed": null,
"dateSyndicationCaptured": null,
"dateSyndicationUpdated": null,
"dateSyndicationVisible": null,
"extendedAttributes": [],
"extension": {}
}
Retrieve media available in the Content Services system.
All parameters are optional. All valid Date
parameters are in the ISO 8601 format: yyyy-MM-ddTHH:mm:ssZ
children
attribute of a media item.
parents
attribute of a media item.
geoTags
object.
geoTags
object.
geoTags
object.
geoTags
object.
geoTags
object.
geoTags
object.
Returns the media object in the results of the response.
List of Media:
GET https://tools.cdc.gov/api/v2/resources/media
Full-Text search:
GET https://tools.cdc.gov/api/v2/resources/media?q={STRING}
MediaType search:
GET https://tools.cdc.gov/api/v2/resources/media?mediatypes={MEDIA_TYPE_NAME}
Name search:
GET https://tools.cdc.gov/api/v2/resources/media?name={STRING}
Topic search:
GET https://tools.cdc.gov/api/v2/resources/media?topic={STRING}
Topic Id search:
GET https://tools.cdc.gov/api/v2/resources/media?topicids={CSV}
Audience search:
GET https://tools.cdc.gov/api/v2/resources/media?audience={STRING}
Language Name search:
GET https://tools.cdc.gov/api/v2/resources/media?languagename={STRING}
Language IsoCode search:
GET https://tools.cdc.gov/api/v2/resources/media?languageisocode={STRING}
Source Name search:
GET https://tools.cdc.gov/api/v2/resources/media?sourcename={STRING}
Source Acronym search:
GET https://tools.cdc.gov/api/v2/resources/media?sourceacronym={STRING}
Show Child Level search:
GET https://tools.cdc.gov/api/v2/resources/media/{ID}?showchildlevel={POSITIVE_INTEGER}
Show Parent Level search:
GET https://tools.cdc.gov/api/v2/resources/media/{ID}?showparentlevel={POSITIVE_INTEGER}
Cache search:
GET https://tools.cdc.gov/api/v2/resources/media?ttl={POSITIVE_INTEGER}
Retrieves the details of a media that can be syndicated.
Returns the media object in the results of the response if a valid identifier was provided.
GET https://tools.cdc.gov/api/v2/resources/media/{MEDIA_ID}
Order the items returned using the attribute names of the media object.
Ascending is the default sort direction. The minus sign (—) is used to denote Descending.
Returns the media object in the results of the response.
ASC:
GET https://tools.cdc.gov/api/v2/resources/media?sort={ATTRIBUTE_NAME}
DESC:
GET https://tools.cdc.gov/api/v2/resources/media?sort=—{ATTRIBUTE_NAME}
ASC:
GET https://tools.cdc.gov/api/v2/resources/media?sort={ATTRIBUTE_NAME}&order=ASC
DESC:
GET https://tools.cdc.gov/api/v2/resources/media?sort={ATTRIBUTE_NAME}&order=DESC
Divide the returned items into multiple result sets (pages).
The pagination object in the response (meta) contains the URLs for the current, previous, and next page.
Returns the media object in the results of the response.
OPTION 1:
GET https://tools.cdc.gov/api/v2/resources/media?max={POSITIVE_INTEGER}&pagenum={POSITIVE_INTEGER}
OPTION 2:
GET https://tools.cdc.gov/api/v2/resources/media?max={POSITIVE_INTEGER}&offset={POSITIVE_INTEGER}
OPTION 3:
GET https://tools.cdc.gov/api/v2/resources/media?max={POSITIVE_INTEGER}&offset={POSITIVE_INTEGER}&pagenum={POSITIVE_INTEGER}
Retrieve the embedded code used to display and process the syndicated HTML content of a media.
All Syndication parameters are valid.
GET https://tools.cdc.gov/api/v2/resources/media/{MEDIA_ID}/embed
"results": "{HTML Embed Code}"
Retrieve the syndicated HTML content of a media.
br
elements are stripped from the results.
GET https://tools.cdc.gov/api/v2/resources/media/{MEDIA_ID}/syndicate
"results": {
"mediaId": 64,
"mediaType": "HTML",
"sourceUrl": "http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6120a3.htm",
"targetUrl": "http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6120a3.htm",
"name": "Smoking is bad, 1998–2010",
"description": "",
"content": "{SYNDICATED HTML}"
}
Returns Syndication content
as defined by the parameters for a Media Type.
GET https://tools.cdc.gov/api/v2/resources/media/{MEDIA_ID}/content
List of the available media types.
GET https://tools.cdc.gov/api/v2/resources/mediatypes
"results": [
{
"name": "Video",
"description": "Videos",
"displayOrdinal": 2
},
{
"name": "HTML",
"description": "HTML Content",
"displayOrdinal": 3
},
{...}
]
List of the available topics.
items
attribute when set to true.
GET https://tools.cdc.gov/api/v2/resources/topics
"results": [
{
"id": 1,
"name": "Diseases & Conditions",
"description": "Diseases & Conditions",
"language": "English",
"mediaUsageCount": 267,
"displayOrdinal": 0,
"items": [ ]
},
{...}
]
List of the available audiences.
GET https://tools.cdc.gov/api/v2/resources/audiences
"results": [
{
"id": 25,
"name": "Parents",
"description": null,
"language": "English",
"mediaUsageCount": 1,
"displayOrdinal": 0,
"items": [ ]
},
{...}
]
List of the available tags.
GET https://tools.cdc.gov/api/v2/resources/tags
"results": [
{
"id": 1,
"name": "Diseases & Conditions",
"language": "English",
"type": "Topic"
},
{...}
]
Retrieves a tag object using its id.
Returns the tag object in the results of the response if a valid identifier was provided.
GET https://tools.cdc.gov/api/v2/resources/tags/{TAG_ID}
Retrieves media objects using a tag id.
Returns the media object in the results of the response if a valid identifier was provided.
GET https://tools.cdc.gov/api/v2/resources/tags/{TAG_ID}/media
Retrieves tag objects related to another tag.
Returns the tag object in the results of the response if a valid identifier was provided.
GET https://tools.cdc.gov/api/v2/resources/tags/{TAG_ID}/related
List of the available tag types.
GET https://tools.cdc.gov/api/v2/resources/tagtypes
"results": [
{
"id": 1,
"name": "Topic",
"description": "Topic"
},
{
"id": 2,
"name": "Audience",
"description": "Audience"
},
{...}
]
List of the available Languages.
GET https://tools.cdc.gov/api/v2/resources/languages
"results": [
{
"name": "English",
"isoCode": "eng"
},
{...}
]
List of the available Organizations.
GET https://tools.cdc.gov/api/v2/resources/organizations
"results": [
{
"id": 356,
"name": "CDC",
"website": [
{
"url": "http://m.cdc.gov",
"isDefault": false
},
{
"url": "http://www.cdc.gov"
"isDefault": true
}
],
"type": "U.S. Federal Government",
"typeOther": null,
"description": "U.S. Federal Government",
"address": "Clifton Rd.",
"addressContinued": null,
"city": "Atlanta",
"stateProvince": "GA",
"postalCode": "30333",
"county": "Fulton",
"country": "US"
},
{...}
]
List of the available Organization Types.
GET https://tools.cdc.gov/api/v2/resources/organizationtypes
"results": [
{
"type": "U.S. Federal Government",
"description": "U.S. Federal Government",
"displayOrdinal": 1
},
{...}
]
List of the available Sources.
GET https://tools.cdc.gov/api/v2/resources/sources
"results": [
{
"name": "Centers for Disease Control and Prevention",
"acronym": "CDC",
"websiteUrl": "http://www.cdc.gov",
"largeLogoUrl": null,
"smallLogoUrl": null,
{...},
{...}
}
]
Only "backwards-incompatible" changes to the API are reflected.
What changes are consider to be “backwards-compatible”?
Details:
string
to "id" integer
.
string
to language object.
string
to source object
{
"id": 16,
"language": {
"name": "English",
"isoCode": "eng"
},
"source": {
"name": "Centers for Disease Control and Prevention",
"acronym": "CDC",
"websiteUrl": null,
"largeLogoUrl": null,
"smallLogoUrl": null
},
"datePublished": "2013-04-01T12:00:00Z",
...
}
Details:
string
"mediaId" to integer
on the response object.