An API utility wrapper for accessing the e-Manifest hazardous waste tracking system maintained by the US Environmental Protection Agency
Project description
e-Manifest
emanifest is a client library for accessing the e-Manifest REST APIs of the US Environmental Protection Agency's RCRAInfo national electronic hazardous waste management system.
Note: The emanifest package was substantially refactored after version 1.1.0 and was released as a new major version at 2.0.0. Code relying on version 1.1.0 should not upgrade to version 2.0.0 of this package without refactoring.
Contents
Requirements
- Python 3.6
Dependencies
- requests
- requests_toolbelt
Installation
emanifest can be installed directly from the Python package directory using pip:
pip install emanifest
Usage
Getting Started
Before using the emanifest package, ensure you have a RCRAInfo user account and the necessary permissions to generate an API ID and key.
All methods to access the e-Manifest APIs are implemented by the RcrainfoClient class which needs to be authenticated with your API ID and Key. A new instance of the class can be initiated with the new_client()
convenience function like so:
from emanifest import client as em
rcra_client = em.new_client('preprod')
rcra_client.Auth('YOUR_API_ID', 'YOUR_API_KEY')
new_client()
accepts a string, either preprod, prod, or a complete base URL. To register for a testing account in preproduction, visit the preprod site. The RcrainfoClient stores the JSON web token and its expiration period (20 minutes). Currently, the emanifest python package does not automatically reauthenticate.
Methods
After authenticating, you are ready to use the full functionality of the emanifest package. An introductory example script can be found here. The RcrainfoClient class exposes a method for each API endpoint in one of the 10 service catagories. For more information about these services, visit the Swagger page of your selected environment. (PREPROD, PROD). API endpoints designed for use by other groups, such as regulators or industry users, will return 'Access Denied' errors if you are not authorized to access these resources in RCRAInfo.
- [All users] Authentication services
- [All users] e-Manifest Lookup Services
- [All users] Lookup Services
- [All users] Site Services
- [Industry users] e-Manifest Services
- [Industry users] e-Manifest UI Link Services
- [Regulator users] CM&E Evaluation Services
- [Regulator users] e-Manifest Services
- [Regulator users] Handler Services
- [Regulator users] User Services
Content will be returned as a RcraResponse object, which wraps around the requests.Response object. Methods that download file attachments are decoded and returned in the RcrainfoResponse.multipart_json
and RcrainfoResponse.multipart_zip
when appropriate. The entire request.Response
object is returned in RcrainfoResponse.response
. Methods that update, correct, or save manifests by uploading new .json and/or .zip files require a file path.
Examples:
rcra_client.GetSiteDetails('VATEST000001')
Once you've confirmed this is the correct site, you might search for manifests in transit from that site:
rcra_client.SearchMTN(siteId='VATEST000001', status='InTransit')
If one of those manifests didn't match your records, you could initiate a correction with the correct JSON information and optionally any attachments (.zip):
rcra_client.Correct('manifest_file_name.json', 'optional_attachments.zip')
Help
If you are uncertain how to use a function, run help(em.FunctionName) in your Python environment. This will return a description of the function, any required inputs, and the formats of those inputs. For a list of all the functions contained in emanifest and additional information about this package, run help(emanifest) in your Python environment.
Contact
Please direct questions to the EPA e-Manifest team at USEPA/e-manifest
Disclaimer
The United States Environmental Protection Agency (EPA) GitHub project code is provided on an "as is" basis and the user assumes responsibility for its use. EPA has relinquished control of the information and no longer has responsibility to protect the integrity, confidentiality, or availability of the information. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by EPA. The EPA seal and logo shall not be used in any manner to imply endorsement of any commercial product or activity by EPA or the United States Government.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for emanifest-2.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c424cbb2cc2faf49a1e7d86aa5b0cf4e695343503345d0db691e452c2ae094a0 |
|
MD5 | bcb4f9f3b0e6dfc2d8901febef6a0820 |
|
BLAKE2b-256 | 16a67d5f7155fdc1462902aea872ad85d2f927ffa2b82184efaf6e2ce06c4bd2 |