Skip to content

RaptorMaps/raptormaps-api-examples

Repository files navigation

raptormaps-api-examples

Welcome to Raptor Maps' API repo. This is an add on to our API documentation found at https://docs.raptormaps.com/reference/reference-getting-started and is meant to provide more detailed examples of our workflows. These example scripts are meant to show how to chain API together in order to achieve a result rather than providing in-depth examples of singular requests. For that more detailed assistance, look at Raptor Maps' public collection in Postman.

All the scripts are written in Python and most can be run as-is. They can also easily be adapted to other languages in order to pull data into systems like Power BI.

These scripts will all require authorization. There are specific instructions for finding the client ID and client secret in the documentation linked above. In order for the scripts to work as-is, these values should be stored in your environment:

export ORG_ID = export CLIENT_ID = export CLIENT_SECRET =

upload_files_from_local.py

This script is designed to be an example of how to upload from local to s3 to Raptor Maps. If the files are already in a remote storage like s3 or Azure, upload_files_from_remote might be a better example (see below).

upload_files_from_remote.py

This script can be used as an example for uploading files hosted remotely into Raptor Maps system.

create_equipment_note.py

create_equipment_note.py: A working example of how to create an equipment note that has 1 file attachment.

An upload session is first created for the file to be uploaded. The file is uploaded to Raptor Maps cloud storage, a note is created for the specific piece of equipment with a title and description, and finally the file is associated to the note.

In addition to the environment variables script requires specifying the solar farm id and the equipment id.

get_map_exports.py

This get_map_extracts.py script runs a series of requests against Raptor Maps API. The end result is a list of zip files containing the files generated by the map export functionality in the Raptor Solar product.

The script begins by pulling a token with which to authenticate to Raptor Maps. This requires two pieces of information be set in the environment, client_secret, and client_id. Instructions for finding those can be found here: https://docs.raptormaps.com/reference/reference-getting-started

Next, the script retrieves all farms associated with the organization to which you belong. This value has been parametrized and needs to be set in the environment as well. This particular step is a paginated request that runs until there are no more farms returned.

We then pull all the inspections for all the farms. This particular implementation takes advantage of python's task handler. It runs multiple requests at once which allows us to build the list of inspections much faster. We added a retry because python gets overeager and sends too many requests at once which produces a back off rquest from the server. This retry allows the operation to complete successfully. The inspections are then sorted for recency and the id of the latest is added to an array we will iterate through in part four.

Last thing we do is to take the array of inspection ids and iterate over it. We use each inspection id to request the map exports files. If there are no files, the script will produce an empty zip.

get_all_findings.py

This script pulls the findings data for the latest inspection for each farm. The structure is very similar to get_map_exports since they're pulling a lot of the same data - farms and inspections are the basis for both operations. The end result for this script is a single csv file with the inspection ID and the farm name appended to each line. This will enable the csv to be processed once all the data is retrieved.

In table form, this looks something like this:

anomaly anomaly_count est_affected_dc_kw est_affected_dc_percent est_annual_impact_kw_h est_annual_impact_dollars module_count farm_name inspection_id
Cell 2 0.27 0.7 111.96 20.5 2 Test Farm 3
Module 19 7.79 19.97 11685.0 111.25 19 Test Farm 3

About

API examples for Raptor Maps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages