Create a Media Library App
Before you get started developing your Media Library App, make sure to create a Hootsuite App and take a look at the sample Media Library App. If you prefer to skip this guide and dive into the API Spec instead, you can find it here.

Step 1 - Define your route and endpoint
The Media API requires Apps to implement the GET /v1/media endpoint. This endpoint will be responsible for calling the external media source to retrieve data and can take in optional query parameters for searching and paging.
An example using the Express framework running on Node.js may look something like this:
app.use('/v1/media', (req, res, next) => {
axios({
method:'get',
url: API_URL,
params: {
client_id: CLIENT_ID,
page: req.query.cursor ? 2 : 1,
query: req.query.query || 'owls',
per_page: req.query.pageSize || 25
}
});
Step 2 - Implement the API
Once you’ve retrieved the data from the external data source, you will need to transform it into the predefined API response we expect. Click here to see the Media Predefined API Spec.
Following the example above, within the response block, first we would need to map the media items we received into what the Media API expects. Note that each media item should have a mimeType: if the url does not contain a file extension, the mimeType cannot be inferred.
For video media, the following must be included.
- The duration (in seconds) must be provided, and a subtitles file in SubRip (.srt) format is optional. The subtitles file name must follow the Facebook SubRip naming convention.
- The
content-lengthHTTP header with value in length indicating the size of the media must be passed in the original url. Click here to see the content-length.
var mediaItems = response.data.map(function(r) {
return {
id: r.id,
thumbnail: {
url: r.urls.thumb,
width: parseInt(r.urls.thumb.match(/w=([^&]*)/)[1]),
height: parseInt((r.urls.thumb.match(/w=([^&]*)/)[1] * r.height) / r.width),
sizeInBytes: r.thumbnailSize,
},
original: {
url: r.urls.raw,
width: r.width,
height: r.height,
sizeInBytes: r.fileSize,
},
name: "temp"+r.id+".jpg",
source: {
name: API,
tos: TOS_URL
},
mediaType: "image",
mimeType: "image/jpg"
}
var mediaItems = response.data.map(function(r) {
return {
id: r.id,
thumbnail: {
url: r.urls.thumb,
width: parseInt(r.urls.thumb.match(/w=([^&]*)/)[1]),
height: parseInt((r.urls.thumb.match(/w=([^&]*)/)[1] * r.height) / r.width),
sizeInBytes: r.thumbnailSize,
},
original: {
url: r.urls.raw,
width: r.width,
height: r.height,
sizeInBytes: r.fileSize,
},
name: "temp"+r.id+".mp4",
source: {
name: API,
tos: TOS_URL
},
mediaType: "video",
mimeType: "video/mp4",
subtitlesFileName: "example.en_US.srt",
subtitles: r.urls.subtitles,
durationInSeconds: r.duration
}
Then, we build out and return the response object our App would be expected to return from the GET /v1/media Endpoint.
var mediaResponse = {
data: mediaItems,
metadata: {
cursor: {
// These are mock values used to demonstrate paging
next: "encodedu93j3jdf8j3jdyhqnnhhpg=2",
previous: "encodedxjatcd83nn39d99093kkprev"
}
}
}
res.json(mediaResponse);
Step 3 - Deploy your App
Once you’ve implemented the relevant predefined API, deploy your App. You can either setup your App to run locally, or use an externally hosted server such as Heroku (also see our Guide to deploying to Heroku).
Step 4 - Run the tests to verify your App
Once you have an accessible URL that your App is running on, run the Runscope tests we’ve created to verify your App implementation. The README inside the sample Media Library App contains instructions on how to setup the Runscope tests. If there are any failures, revisit your implementation to make sure it meets the Media API Spec. If these tests pass, you’re ready to submit your App for approval!
Step 5 - Submit your App for approval
Now that your Media Library App is functioning as expected, you can update the URL for your App if needed and submit it for approval.