Skip to content

Getting Started with SWODLR‐API

Josh Garde edited this page Oct 11, 2023 · 1 revision

The primary entrypoint into the SWODLR system is the swodlr-api service. This service is a GraphQL-first API allowing for user-facing interactions with the larger system.

Authentication

To authenticate with the service, an EDL token may be sent as part of every request as part of an HTTP Authorization header bearer token. For example:

Authorization: Bearer [TOKEN HERE]

Base Endpoint

The primary endpoint for the API is /graphql. Only a POST requests are allowed to this endpoint containing the query to execute and the variables that are associated with the query. This is typically done as a JSON object. The additional details about this request can be found here: https://graphql.org/learn/serving-over-http/#post-request

Examples

Some example API queries are provided below:

Current user details

{
	currentUser {
		id
		firstName
		lastName
		email
	}
}

Retrieving a user's product history

{
	currentUser {
		products {
			id
			cycle
			pass
			scene
			outputSamplingGridType
			rasterResolution
			outputGranuleExtentFlag
			mgrsBandAdjust
			utmZoneAdjust
			
			granules {
				id
				timestamp
				uri
			}
			
			status {
				id
				state
				reason
				timestamp
			}
		}
	}
}

Querying a user's current raster definitions

query {
	currentUser {
		rasterDefinitions {
			name
			id
			outputSamplingGridType
			rasterResolution
			outputGranuleExtentFlag
			mgrsBandAdjust
			utmZoneAdjust
		}
	}
}

Creating a raster definition

mutation (
	$name: String!,
	$outputGranuleExtentFlag: Boolean!
	$outputSamplingGridType: GridType!,
	$rasterResolution: Int!
	$utmZoneAdjust: Int,
	$mgrsBandAdjust: Int
){
	createRasterDefinition(
		name: $name,
		outputGranuleExtentFlag: $outputGranuleExtentFlag,
		outputSamplingGridType: $outputSamplingGridType,
		rasterResolution: $rasterResolution,
		utmZoneAdjust: $utmZoneAdjust,
		mgrsBandAdjust: $mgrsBandAdjust
	) {
		id
	}
}

Variables:

{
	"name": "Test_2",
	"outputGranuleExtentFlag": false,
	"outputSamplingGridType": "UTM",
	"rasterResolution": 100,
	"utmZoneAdjust": 0,
	"mgrsBandAdjust":0
}

Deleting a raster definition

mutation ($id: ID!) {
	deleteRasterDefinition(id: $id)
}

Variables:

{
	"id": "40b491cc-d143-47b6-bc94-9013356b6397"
}

Generating a raster product

mutation Test (
	$cycle: Int!
	$pass: Int!
  $scene: Int!
	$outputGranuleExtentFlag: Boolean!
	$outputSamplingGridType: GridType!
	$rasterResolution: Int!
	$utmZoneAdjust: Int
	$mgrsBandAdjust: Int
){
	generateL2RasterProduct(
		cycle: $cycle,
		pass: $pass,
		scene: $scene,
		outputGranuleExtentFlag: $outputGranuleExtentFlag
		outputSamplingGridType: $outputSamplingGridType
		rasterResolution: $rasterResolution
		utmZoneAdjust: $utmZoneAdjust
		mgrsBandAdjust: $mgrsBandAdjust
	) {
		id
		status {id, state}
	}
}

Variables

{
	"cycle": 1,
	"pass": 401,
	"scene": 125,
	"outputGranuleExtentFlag": false,
	"outputSamplingGridType": "UTM",
	"rasterResolution": 10000,
	"utmZoneAdjust": 0,
	"mgrsBandAdjust": 0
}

Retrieving a status by product ID

{
	statusByProduct(product: "07f9795e-7d11-481a-9ebd-ac51fc66d3f3") {
		id
		state
		timestamp
		reason
	}
}