Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
This project exports a single Python class that can be used to make HTTP requests to the
Hakai API resource server.
The exported Client
class extends the functionality of the
Python requests library to supply Hakai
OAuth2 credentials with url requests.
Python 3.8 or higher is required. Install with pip:
pip install hakai-api
from hakai_api import Client
# Get the api request client
client = Client() # Follow stdout prompts to get an API token
# Make a data request for chlorophyll data
url = '%s/%s' % (client.api_root, 'eims/views/output/chlorophyll?limit=50')
response = client.get(url)
print(url) # https://hecate.hakai.org/api/eims/views/output/chlorophyll...
print(response.json())
# [{'action': '', 'event_pk': 7064, 'rn': '1', 'date': '2012-05-17', 'work_area': 'CALVERT'...
This library exports a single client name Client
. Instantiating this class produces
a requests.Session
client from the Python requests library. The Hakai API Python
Client inherits directly from requests.Session
thus all methods available on that
parent class are available. For details see
the requests documentation.
The hakai_api Client
class also contains a property api_root
which is useful for
constructing urls to access data from the API. The
above Quickstart example demonstrates using this property to construct a
url to access project names.
For details about the API, including available endpoints where data can be requested from, see the Hakai API documentation.
You can specify which API to access when instantiating the Client. By default, the API
uses https://hecate.hakai.org/api
as the API root. It may be useful to use this
library to access a locally running API instance or to access the Goose API for testing
purposes. If you are always going to be accessing data from a locally running API
instance, you are better off using the requests.py library directly since Authorization
is not required for local requests.
from hakai_api import Client
# Get a client for a locally running API instance
client = Client("http://localhost:8666")
print(client.api_root) # http://localhost:8666
You can also pass in the credentials string retrieved from the hakai API login page while initiating the Client class.
from hakai_api import Client
# Pass a credentials token as the Client Class is initiated
client = Client(credentials="CREDENTIAL_TOKEN")
Finally, you can set credentials for the client class using the HAKAI_API_CREDENTIALS
environment variable. This is useful for e.g. setting credentials in a docker container.
The value of the environment variable should be the credentials token retrieved from the
Hakai API login page.
See CONTRIBUTING
See LICENSE
FAQs
Get Hakai database resources using http calls
We found that hakai-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.