Reading commits via API is the simplest way to access asset histories. Here is an example of how you can use the curl command to make a GET request to the specified endpoint using your Capture Token and the Nid of the asset you want to query. If you do not have a Capture Token yet, please follow the instruction and create one.
API Endpoint: https://eohakmlw1xjl7ut.m.pipedream.netCost:0, free to useMethod:GETDescription:This endpoint allows you to retrieve information about a specific nid. Replace "NID_TO_QUERY"with the specific nid you wish to retrieve information about.Parameters:Parameter Type Required Descriptionnid text Yes The nid of the asset to retrievetestnet text No true to query on Testnet (snow)tmp_token text No tmp_token to access private assetsAuthentication:The API requires a valid token for Authorization. You can pass it in the headers of the request usingthe following format:"Authorization: token YOUR_CAPTURE_TOKEN"Headers:Content-Type:application/jsonAuthorization:tokenYOUR_CAPTURE_TOKENExamples:curl -XGET -H"Content-Type: application/json" \ -H"Authorization: token YOUR_CAPTURE_TOKEN" \"https://eohakmlw1xjl7ut.m.pipedream.net?nid=NID_TO_QUERY"Response:{"nid": AssetNid,"commits": [ {"transaction":COMMIT_TRANSACTION_HASH,"assetTreeCid":ASSET_TREE_NID,"assetTreeSha256":ASSET_TREE_SHA256,"assetTreeSignature":ASSET_TREE_SIGNATURE,"author":AUTHOR_WALLET_ADDRESS,"committer":COMMITTER_WALLET_ADDRESS,"provider":NID_OF_PROVIDER_PROFILE,"timestampCreated":UNIX_TIMESTAMP,"action":ACTION_DESCRIPTION,"actionName":THE_REAL_ACTION_NAME,"actionNid":THE_NID_OF_ACTION,"actionResult":ACTION_RESULT_URL,"abstract":ACTION_DESCRIPTION },... ] }
Detailed explanation of the commit message can be found on the Commit page. In this example, you would replace YOUR_CAPTURE_TOKEN with your actual Capture token and NID_TO_QUERY with the Nid of the asset you want to retrieve information for. More examples can be found below:
import requests# Define the URL for the API endpointurl ="https://eohakmlw1xjl7ut.m.pipedream.net"# Define headers for the request, including the Capture Tokenheaders ={"Content-Type":"application/json","Authorization":"token "+ YOUR_CAPTURE_TOKEN}# Define the query parameter for the nid to be queriedparams ={"nid": NID_TO_QUERY,"testnet":"true"}# Send the GET request to the APIresponse = requests.get(url, headers=headers, params=params)# Check if the request was successfulif response.status_code !=200:print(f"Error: {response.status_code} - {response.text}")else:# Parse the response as JSON json_data = response.json()# Print the "nid" of the asset from the JSON dataprint("nid:", json_data["nid"])# Print the first commit from the "commits" array in the JSON dataprint("First commit:", json_data["commits"][0])
// Define the URL for the API endpointconsturl="https://eohakmlw1xjl7ut.m.pipedream.net";// Define headers for the request, including the Capture Tokenconstheaders= {"Content-Type":"application/json","Authorization":`token ${YOUR_CAPTURE_TOKEN}`};fetch(`${url}/?nid=${NID_TO_QUERY}`, { method:"GET", headers: headers}).then(response => {if (response.ok) {returnresponse.json(); } else {thrownewError(`Error: ${response.status} - ${response.statusText}`); } }).then(jsonData => {// Print the "nid" value from the JSON dataconsole.log("nid:",jsonData.nid);// Print the first commit from the "commits" array in the JSONconsole.log("First commit:", jsonData["commits"][0]); }).catch(error => {console.error(error); });