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.
{
"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, title ASC",
"currentUrl": "https://tools.cdc.gov/api/v1/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.
{
"mediaId": "16",
"title": "Tobacco Use - Winnable Battles",
"description": null,
"mediaType": "HTML",
"tags": {
"topic": [
{
"id": 10,
"name": "Smoking Cessation"
}
]
},
"sourceUrl": "http://www.cdc.gov/winnablebattles/Tobacco/index.html",
"targetUrl": "http://www.cdc.gov/winnablebattles/Tobacco/index.html",
"language": English,
"thumbnailUrl": "https://tools.cdc.gov/api/v1/resources/media/16/thumbnail",
"rating": null,
"ratingCount": null,
"ratingCommentCount": null,
"embedCode": "",
"attribution": null,
"persistentUrl": null,
"status": "Published",
"datePublished": "2013-04-01 12:00:00",
"dateModified": "2013-04-01 12:00:00",
"childCount": 0,
"children": null,
"parentCount": 0,
"sourceCode": "Food and Drug Administration",
"domainName": "http://www.fda.gov/",
"owningOrgId": null,
"owningOrgName": null,
"maintainingOrgId": null,
"maintainingOrgName": null
}
Retrieve media available in the Content Services system.
children
attribute of a media item.
parents
attribute of a media item.
Returns the media object in the results of the response.
List of Media:
GET https://tools.cdc.gov/api/v1/resources/media
Full-Text search:
GET https://tools.cdc.gov/api/v1/resources/media?q={STRING}
MediaType search:
GET https://tools.cdc.gov/api/v1/resources/media?mediatype={MEDIA_TYPE_NAME}
Title search:
GET https://tools.cdc.gov/api/v1/resources/media?title={STRING}
Topic search:
GET https://tools.cdc.gov/api/v1/resources/media?topic={STRING}
Audience search:
GET https://tools.cdc.gov/api/v1/resources/media?audience={STRING}
Language search:
GET https://tools.cdc.gov/api/v1/resources/media?language={STRING}
Show Child Level search:
GET https://tools.cdc.gov/api/v1/resources/media/{ID}?showchildlevel={POSITIVE_INTEGER}
Show Parent Level search:
GET https://tools.cdc.gov/api/v1/resources/media/{ID}?showparentlevel={POSITIVE_INTEGER}
Cache search:
GET https://tools.cdc.gov/api/v1/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/v1/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/v1/resources/media?sort={ATTRIBUTE_NAME}
DESC:
GET https://tools.cdc.gov/api/v1/resources/media?sort=—{ATTRIBUTE_NAME}
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/v1/resources/media?max={POSITIVE_INTEGER}&pagenum={POSITIVE_INTEGER}
OPTION 2:
GET https://tools.cdc.gov/api/v1/resources/media?max={POSITIVE_INTEGER}&offset={POSITIVE_INTEGER}
OPTION 3:
GET https://tools.cdc.gov/api/v1/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/v1/resources/media/{MEDIA_ID}/embed
"results": "{HTML Embed Code}"
Retrieve the syndicated HTML content of a media.
GET https://tools.cdc.gov/api/v1/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",
"title": "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/v1/resources/media/{MEDIA_ID}/content
List of the available media types.
GET https://tools.cdc.gov/api/v1/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/v1/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/v1/resources/audiences
"results": [
{
"id": 25,
"name": "Parents",
"description": null,
"language": "English",
"mediaUsageCount": 1,
"displayOrdinal": 0,
"items": [ ]
},
{...}
]
List of the available Languages.
GET https://tools.cdc.gov/api/v1/resources/languages
"results": [
{
"name": "English",
"description": "English (US)",
"displayOrdinal": 0
},
{...}
]
List of the available Organizations.
GET https://tools.cdc.gov/api/v1/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/v1/resources/organizationtypes
"results": [
{
"type": "U.S. Federal Government",
"description": "U.S. Federal Government",
"displayOrdinal": 1
},
{...}
]