Page tree
Skip to end of metadata
Go to start of metadata

Getting your API Key

Your API authentication key is available from your account's setting. It is a private key and should not be shared.  You can access your account settings from the top menu by clicking on your username. 

The link will open your account's settings page. Your API key is the last element in the side bar. 

Accessing gDMCP using Python


gDMCP API - Add new dataset from g2
#!/usr/bin/env python 
import json
import requests
import sys
import os
from shutil import copyfile
import pprint

# This sample gets the file name and path (from g2) then copy the file to the gDMCP project
# Then upload it to the system
filename, file_extension=os.path.splitext(os.path.basename(sys.argv[1]))
# Put the details of the dataset we're going to create into a dict.  
dataset_dict = {
    'package_id': sys.argv[2],
    'gstar_path': sys.argv[1],
    'url': '',
    'name': filename,
    'notes': filename,

## You need your User API Authorization Key
headers = {
    'Authorization': 'xxxxxxxx-xxxx-xxxxx-xxxx-xxxxxxxxxxxx'

# Use the json module to dump the dictionary to a string for posting.   
# We'll use the package_create function to create a new dataset. 
url =    ''
response =, json=dataset_dict, headers=headers)

# Use the json module to load CKAN's response into a dictionary.   
response_dict = response.json()
assert response_dict['success'] is True

# package_create returns the created package as its result.      
created_package = response_dict['result']
print created_package['url']

More details about the API access to gDMCP can be found on 

  • No labels