TRAC Metadata Endpoint

The TRAC Metadata Endpoint is useful for collecting information about all of the TRAC searches on your entire domain. This endpoint can be used for Top Level search data, & search creation.

Why this Endpoint?

This endpoint can be used not just to retrieve search metadata, but for search creation itself! This includes all the necessary steps involved with search creation, such as previewing and launching historics, starting and stopping your realtime collection, editing your search, and more!

Sample Calls

Intro

Below are a handful of sample calls to help you understand how the TRAC Metadata Endpoint functions

Each sample call will contain the query and variables in one tab, followed by the Response in the other.

We do this to keep formatting consistent with how most API testing environments would surface the blocks as groups.

For all queries, POST to this GraphQL endpoint URL:

https://trac.pulsarplatform.com/graphql

Getting a List of your Running Searches ordered by Name

Use the page option to traverse through if you have more than 10 searches

query Searches($sortBy: AllowedFieldsForSorting, $status: [SearchStatusEnum!], $realtimeStatus: [SearchRealtimeStatusEnum!]){
    searches(sortBy:$sortBy, status:$status, realtimeStatus:$realtimeStatus){
        totalCount
        nodes{
            name
            totalContents
            startDate
            status
            searchHash
        }
    }
}
{
    "sortBy": "NAME",
    "realtimeStatus": [
        "STARTED"
    ],
    "status": [
        "READY"
    ]
}

Though the entire return options are unrequired, it's recommended to use these fields to immediately retrieve the new search hash as well as any potential errors if the setup isn't right

mutation CreateBoolTopic($input: CreateBooleanTopicsSearchInput!){
  createBooleanTopicsSearch(input: $input){
	search{
		name
		searchHash
	}
	errors {
		id
		message
		extensions
	}
  }
}
{
	"input": {
		"name": "MyTestAPISearch",
		"categories": [
			"REDDIT",
			"FORUMS",
			"FACEBOOK"
		],
		"booleanExpression": "cryptocurrency AND (dump OR pump OR \"to the moon\")",
		"facebookKeywords": [
			[
				"cryptocurrency",
				"dump"
			],
			[
				"cryptocurrency",
				"pump"
			],
			[
				"cryptocurrency",
				"to the moon"
			]
		]
	}
}

Note that we are using the search ID instead of the search hash for this mutation: the search ID can also be retrieved via the searches field, or it can be seen in the search URL on platform

mutation CreateHistoric($input: CreateHistoricInput!){
  createHistoric(input: $input){
		errors {
			id
			message
			extensions
		}
	}
}
{
	"input": {
		"searchId": 118429,
		"categories": [
			"REDDIT",
			"FACEBOOK"
		],
		"startDate": "2024-02-20T00:00:00Z",
		"endDate": "2024-03-04T23:59:59Z"
	}
}

The most important bit to grab here if you wish to launch the historic after preview is the id found as the first subfield of nodes. You will use this id to launch the historic.

query PreviewHistorics($sid: ID){
  historics(searchId: $sid){
    totalCount
    nodes{
      id
      startDate
      endDate
      category
      status
      progress
      previewResult
      previewGraphData {
        name
	y
      }
    }
  }
}
{
	"sid": 118429
}

Remember, the historic IDs needed to launch historics can be retrieved from the above query; the above query can also be used to check the status of the launch afterwards. Some searches may still need manual authorization by an internal admin for historics.

mutation launchHistoric($input: LaunchHistoricInput!){
  launchHistoric(input: $input){
		errors {
			id
			message
			extensions
		}
	}
}
{
	"input": {
		"ids": [
			2037212,
			2037213
		]
	}
}

Note the start and end date fields are optional; if they are left out, the search will start immediately and run until it is stopped. These fields are useful for establishing a search schedule.

mutation startSearch($input: StartSearchInput!){
  startSearch(input: $input){
		errors {
			id
			message
			extensions
		}
	}
}
{
	"input": {
		"id": 118429,
		"startDate": "2024-03-05T09:46:00Z",
		"endDate": "2024-03-05T23:59:59Z"
	}
}

Very similar to starting a search, note again the use of the search ID rather than the search hash!

mutation stopSearch($input: StopSearchInput!){
  stopSearch(input: $input){
		errors {
			id
			message
			extensions
		}
	}
}
{
	"input": {
		"id": 118429
	}
}

Last updated