
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
abstract-apis
Advanced tools
The `abstract_apis` module is designed to facilitate HTTP requests in Python applications, particularly those that require handling JSON data, dealing with custom API endpoints, and parsing complex nested JSON responses. The module simplifies request handling by abstracting away common tasks such as header management, URL construction, and response parsing.
The abstract_apis module is a Python utility designed to facilitate HTTP requests in Python applications, with a focus on handling JSON data, interacting with custom API endpoints, and parsing complex nested JSON responses. Particularly, the module provides utilities for HTTP request management essential tasks such as header management, URL construction, and response parsing. It offers both synchronous and asynchronous request capabilities and has extended support for the Solana blockchain APIs via remote procedure call (RPC) requests. Some scripts also provide an interactive GUI for testing API functions and manipulate API response data.
make_request.py and async_make_request.py scripts.abstract_api_calls.py and request_utils.py scripts.body_get.py, solana_rpc_client.py, and variables.py scripts.dbQuery.py.get_api_window.py script.request_utils.py script.-abstract_api_calls
src/abstract_apis/abstract_api_calls.py
The provided script mainly focuses on handling URL management and HTTP post requests for various predefined websites. It starts by defining URLs for three different sites in the get_urls function and then defines multimedia API links for these websites in the get_api_links function. The get_url method is used to verify and return the appropriate URL for a given domain. The get_api_link function is used to concatenate the domain and the endpoint, but also ensures the URL doesn't have repeating sections. make_request_link uses the above helper methods to construct a complete URL and make a post HTTP request using the postRequest function from the imported make_request.py script. The abstract_api_call function is the high-level function that uses make_request_link to return the HTTP response of specific API endpoints from the given websites.
-async_make_request
src/abstract_apis/async_make_request.py
The async_make_request.py script of the abstract_apis module provides a set of methods for handling asynchronous HTTP requests. It relies heavily on the asyncio and aiohttp Python libraries to manage event loops, create client sessions, and send HTTP requests.
The script starts with several utility functions to manage async behavior. The run_async function manages the asyncio event loop to run asyncio coroutines. get_async_response runs an asynchronous function and returns the result using run_async.
The getAsyncRequest, postAsyncRequest, asyncMakeRequest, asyncPostRequest, asyncGetRequest, and asyncGetRpcRequest functions are asynchronous functions that make GET, POST, or RPC requests to a specified URL. They also support handling of response codes, raw responses, response results, nested JSON loading, and authorization.
Finally, the async_get_response is an asynchronous function that handles the response from an HTTP request. If the content type of the response is JSON, it attempts to extract the JSON content and, in case of decoding failure, it will return the raw text of the response.
Overall, this script enhances the abstract_apis module with the ability to manage, execute, and handle asynchronous HTTP requests.
-make_request
src/abstract_apis/make_request.py
The script provided, make_request.py, is part of the abstract_apis package and is found in the src/abstract_apis directory. It appears to be a utility script designed for making HTTP requests and handling the respective responses.
The script starts by importing request utilities from abstract_apis.request_utils and setting up a logging level to suppress logs below WARNING level using python's logging library.
The main function make_request is designed to carry out various types of HTTP requests – specifically GET and POST requests. It accepts a variety of parameters such as the request's URL, data, headers, endpoint, status code, retry_after period, raw response, response result data, loaded nested JSON responses, and authorization details. This function uses the Python requests library to carry out the actual HTTP requests, and its behavior is adjusted according to the specified parameters. If the HTTP method is not 'POST' or 'GET', the function raises a ValueError.
Furthermore, the script includes getRpcData which returns a dictionary with RPC request data, and two wrapper functions postRequest and getRequest that utilize make_request to perform respectively HTTP POST and GET requests.
Overall, this script plays a fundamental role in the abstract_apis module by providing a mechanism to make HTTP requests and retrieve the data at specified endpoints.
-request_utils
src/abstract_apis/request_utils.py
The provided code chunk is a part of the request_utils.py script from the abstract_apis module. The script appears to provide several utility functions to facilitate the making and management of HTTP requests. The function get_headers() returns a dictionary containing a standard 'Content-Type' header. The ensure_json() function verifies if the provided data is in JSON format and if not, it converts it into valid JSON string. The stripit() function is used to strip unwanted characters from strings. make_endpoint() and make_url() are helper functions used to format and clean up endpoint and URL strings respectively. get_url() constructs the URL by concatenating the base URL and the endpoint, after verifying and cleaning each. The get_text_response() function tries to access the text from a response object and returns it, if available. On failure, it simply returns None. These functions help in simplifying the construction of URLs and easier data handling.
The module can be installed via pip. Ensure to have Python version 3.6 or above. The dependencies are abstract_utilities and requests.
pip install abstract_apis
abstract_utilitiesrequestsTypically, the module is imported in your Python script as follows:
from import abstract_apis
Then, specific functions like GET or POST requests can be used as per the requirements.
The project is licensed under the MIT License.
No description available
pip install Unknown Package
FAQs
The `abstract_apis` module is designed to facilitate HTTP requests in Python applications, particularly those that require handling JSON data, dealing with custom API endpoints, and parsing complex nested JSON responses. The module simplifies request handling by abstracting away common tasks such as header management, URL construction, and response parsing.
We found that abstract-apis 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.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.