This guide will walk you through getting up and running with the DVIDS Content Submission API.
dvidsservicedesk@dvidshub.net.The user authenticating must have submitter privileges in a DVIDS unit. Contact your unit PAO for help with this process.
Send the user to:
https://api.dvidshub.net/auth/authorize?client_id=<your-app-key>&redirect_uri=<your-redirect-url>&response_type=code&scope=basic%20email%20upload
Note: The upload scope is required for this application.
redirect_uri with a code querystring parameter.code for an access_token and refresh_token via a POST request.Content-Type: application/x-www-form-urlencodedrefresh_token to obtain new tokens before expiry.Below is an example of how to exchange the authorization code for an access token using Python's requests library:
import requests
def get_oauth_access_token(token_url, client_id, client_secret, code, redirect_uri):
"""
Exchange an authorization code for an access token.
"""
data = {
'grant_type': 'authorization_code',
'code': code,
'redirect_uri': redirect_uri,
'client_id': client_id,
'client_secret': client_secret
}
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
response = requests.post(token_url, data=data, headers=headers)
if response.status_code == 200:
print(response.json())
else:
raise Exception(f"Failed to obtain access token: {response.status_code}, {response.text}")
get_oauth_access_token(
'https://api.dvidshub.net/auth/access_token',
'<your-api-key>',
'<your-secret-key>',
'<your-redirect-uri>',
'<your-authorization-code>'
)
Authorization header with your access token prefixed by Bearer.Content-Type header to application/json.type property in the request body.id property in the request body (as a string).POST /batch endpoint.id for subsequent requests.POST /batch/<batch_id>/news endpoint.batch_id from the previous step.GET /country endpoint to list available country codes.name querystring parameter to search by full or partial country name.iso2 code in the response to set the country field when creating a news story.Photo or Video.POST /batch/<batch_id>/upload endpoint.type attribute is required in the request body.upload_url for uploading media files and an id to reference in future requests.PUT request.Content-Type header.Transfer-Encoding: chunked — it is not supported and will return a 501 error.POST /batch/<batch_id>/photo endpoint.id from the upload step as the batch_upload relationship.instructions block is required and must include public release authority information.virin field is required for photos and videos and should be unique.GET /service-unit endpoint to list available service units.Use:
GET /author to list all authorsGET /service-unit/<service_unit_id>/author to filter by unitPOST /author/<author_id>/virincreated_at date of the photo/videoPOST /service-unit/<service_unit_id>/virinPOST /batch/<batch_id>/multipart-uploadid for future requests.POST /batch/<batch_id>/multipart-upload/<upload_id>/partupload_url to upload the part.ETag from the PUT response — needed for finalization.PATCH /batch/<batch_id>/multipart-upload/<upload_id>POST /batch/<batch_id>/videoid from the multipart upload as the batch_upload relationship.POST /batch/<batch_id>/news/<news_id>/mediais_primary flag for the main asset if multiple are attached.PATCH /batch/<batch_id>closed: true in the request body.Check unit approval workflow status with GET /service-unit/<service_unit_id>.
If approval is required, assets will not be publicly available until approved.
GET /batch/<batch_id> — List all assetsGET /batch/<batch_id>/photo/<photo_id> — Check photo statusGET /batch/<batch_id>/video/<video_id> — Check video statusBefore uploading, check if the photo already exists:
GET /photo with ahash, phash, dhash, and whashvirincreated_at or virin to confirm duplicationTo suppress batch close emails (useful for bulk processing):
PATCH /batch/<batch_id> endpoint in the API documentation