NAV Navbar
Logo
shell JavaScript json

Introduction

Welcome to the Streetlytics API. You can use our API to access API endpoints, which can get information on the APIs.

We have language bindings in Shell. You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

You can see and test example API calls here.

Authorization

The Streetlytics API uses JSON Web Tokens (JWTs) for authorization. The first call the user should make should be either /getToken with a username and password to receive a new api key or /isValidToken to ensure their existing key is still valid. The user should then form a token by preceeding the key with ‘jwt’. All tokens take the form ‘jwt APIKEY’ where APIKEY is returned by the getToken call. Note, the javascript client will automatically prepend API keys with jwt. Afterwards, all calls indicated as requiring authorization should set the Authorization header of the request with the JWT.

Responses

Where not indicated, a blank response with status 200 indicates success

Segments

This is an API call for segments.

[POST] /segments shell curl -X POST -H 'Content-Type:application/json' -H 'Authorization:jwt $APIKEY' -d '{"lng":$LNG, "lat":$LAT}' $BASEURL:5000/segments

  // Example 200 response
  {
    p: {
      attributes: [
        "geojson", 
        "road_name", 
        "func_class", 
        "dir", 
        "totda", 
        "totam", 
        "totmd", 
        "totpm", 
        "totop", 
        "ampkdir", 
        "pmpkdir", 
        "perdacmn", 
        "perdaedn", 
        "perdalcn", 
        "sumdaicn", 
        "avgdaicn", 
        "avgdahhn", 
        "avgdaagn", 
        "totdaic1n", 
        "totdaic2n", 
        "totdaic3n", 
        "totdaic4n", 
        "totdahh1n", 
        "totdahh2n", 
        "totdahh3n", 
        "totdahh4n", 
        "totdahh5n", 
        "totdaag1n", 
        "totdaag2n", 
        "totdaag3n", 
        "totdaag4n", 
        "totdacl01n", 
        "totdacl02n", 
        "totdacl03n", 
        "totdacl04n", 
        "totdacl05n", 
        "totdacl06n", 
        "totdacl07n", 
        "totdacl08n", 
        "totdacl09n", 
        "totdacl10n", 
        "totdacl11n", 
        "totdacl12n", 
        "totdacl13n", 
        "totdacl14n", 
        "totdacl15n", 
        "totdacl16n", 
        "totdacl17n", 
        "totdacl18n", 
        "totdacl19n", 
        "totdacl20n", 
        "totdacl21n", 
        "totdacl22n", 
        "totdacl23n", 
        "totdacl24n", 
        "totdacl25n", 
        "totdacl26n", 
        "totdacl27n", 
        "totdacl28n", 
        "totdacl29n", 
        "totdacl30n", 
        "totdacl31n", 
        "totdacl32n", 
        "totdacl33n", 
        "totdacl34n", 
        "totdacl35n", 
        "totdacl36n", 
        "totdacl37n", 
        "totdacl38n", 
        "totdacl39n", 
        "totdacl40n", 
        "totdacl41n", 
        "totdacl42n", 
        "totdacl43n", 
        "totdacl44n", 
        "totdacl45n", 
        "totdacl46n", 
        "totdacl47n", 
        "totdacl48n", 
        "totdacl49n", 
        "totdacl50n", 
        "totdacl51n", 
        "totdacl52n", 
        "totdacl53n", 
        "totdacl54n", 
        "totdacl55n", 
        "totdacl56n", 
        "totdacl57n", 
        "totdacl58n", 
        "totdacl59n", 
        "totdacl60n", 
        "totdacl61n", 
        "totdacl62n", 
        "totdacl63n", 
        "totdacl64n", 
        "totdacl65n", 
        "totdacl66n", 
        "totdacl67n", 
        "totdacl68n"
  ]   
      num_segments: 50,
      paging: {
        num_segments: 0,
        page_number: 1,
        segments_per_page: 10000,
        total_pages: 1,
        total_segments: 1281
      },
      segments: ["the attributes above, in the same order"]
    },
    success: true,
    user_data: null
  }
getSegmentsPoint(apiKey,latitute,longitue)
getSegmentsBbox(apiKey, west, south, east, north)
Parameter Type Required Default Description
segments_result_type string false COMPRESSED Choose how to display the results data. options COMPRESSED, COMPRESSED_NO_ATTRIBUTE_NAMES, PURE_GEOJSON
segments_limit int false 10000 Limits the segment list ex. 500
paging boolean false false Whether to show pagination
search_type string false point Search by point or bbox. bbox parameter must be in BBOX format
dir string false none Filters by selected direction
road_name string false none Restricts search to roads with specified name
road_name_match_type string false none How to match against the provided road name. Options: EXACT, LEFT_MATCH, IS_NOT_EXACT, EXACT_WITH_DIR_PREFIXES
func_classes int false none Use a function class of 1 to 5
lat float false none latitude of a point
lng float false none longitude of a point
radius float false 0 radius to search withing
bbox string false none string of four floats seperated by commas that represent a bounded box

Notes

if the segment_result_type is point (default), lat and lng are required. if segment_result_type is bbox, bbox is required

Get token

This is an API call that allows the user to create a token.

[POST] /getToken shell curl -X POST -H 'Content-Type:application/json' -d '{"username":"$USERNAME", "password":"$PASSWORD"}' $BASEURL:5000/getToken

  {
    token: "abc123...xyz"
  }
getToken(username, password)

Parameters

Parameter Type Default Description
username string None The user who is to receive the token
password string None User password
persist boolean False Determines whether to use a temporary token, or a long-term token

Notes

There are two types of tokens: a temporary token and a long-term token. The long-term token can be set by passing the boolean value True to the parameter persist. The default token is the temporary one.

There is a maximum number of persisted tokens available.

Is valid token

If the user is logged in this will return a blank 200 status response. Otherwise it will return a 401, unauthorized

[POST] /isValidToken shell curl -X POST -H 'Content-Type:application/json' -H 'Authorization:jwt $APIKEY' $BASEURL:5000/isValidToken javascript isValidToken(apiKey)

Notes

Get Persisted Tokens

Returns all persisted tokens for the current user

[POST] /getPersistedTokens shell curl -X POST -H 'Content-Type:application/json' -H 'Authorization:jwt $APIKEY' $BASEURL:5000/getPersistedTokens javascript getPersistedTokens(apiKey) json { "tokens": [ { "expires_on": $EPOCH, "token": "$TOKEN" } ] }

Revoke Persisted Token

Revokes a token for the current user

[Post] /revokePersistedToken

Parameter Type Description
token String the token to be revoked

Notes

the token passed should NOT be preceeded by ‘jwt’

curl -X POST -H 'Content-Type:application/json' -H 'Authorization:jwt $APIKEY' -d '{"token":"$APIKEY"}'  $BASEURL:5000/revokePersistedToken
revokePersistedToken(apiKey, token)

Change password

Changes password of the current user.

[POST] /changePassword

Parameter Type Description
new_password String The new password for the current user
curl -X POST -H 'Content-Type:application/json' -H 'Authorization:jwt $APIKEY' -d '{"new_password":"$PASSWORD"}'  $BASEURL:5000/changePassword

Notes

The new password must meet complexity requirements.

changePassword(apiKey, new_password)

Forgot password

Generates a new password and sends an email to the specified customer.

[POST] /forgotPassword

Parameter Type Description
username string Email address of user
curl -X POST -H 'Content-Type:application/json' -d '{"email":"$email"}' $BASEURL:5000/forgotPassword
forgotPassword(email)

Notes

If the user exists, a newly generated password is sent to the email address on file.

Errors

The Streetlytics API uses the following error codes:

Error Code Meaning
400 Bad Request – Information sent is invalid
401 Unauthorized – Authorization credentials are invalid