A modern Python client library for the RIPE Database REST API. PyRipe provides a clean, type-safe interface to interact with RIPE's RESTful web services, built with Pydantic for robust data validation and serialization.
- Full REST API Coverage: Support for all RIPE Database operations including search, create, update, and delete
- Type Safety: Built with Pydantic models for compile-time type checking and runtime validation
- Dual Environment Support: Seamless switching between production (RIPE) and test environments
- Rich Query Options: Advanced search capabilities with filtering, tagging, and flags
- Error Handling: Comprehensive exception handling with detailed error messages
- Modern Python: Requires Python 3.13+ and uses type hints throughout
pip install pyripeOr using Poetry:
poetry add pyripefrom pyripe import RipeRestApiClient
# Use RIPE production environment
client = RipeRestApiClient(source="RIPE")
# Or use test environment
client = RipeRestApiClient(source="TEST")
# With basic authentication
client = RipeRestApiClient(source="RIPE", basic_auth="your_base64_auth")# Simple search
result = client.search("192.168.1.1")
# Advanced search with filters
result = client.search(
query="192.168.1.1",
sources=["RIPE"],
type_filters=["inetnum", "route"],
limit=10,
offset=0
)from pyripe.models import Attributes, Attribute
# Define the primary key attributes
pk = Attributes(attribute=[
Attribute(name="inetnum", value="192.168.1.0 - 192.168.1.255")
])
# Get the object
result = client.get_object(pk)from pyripe.models import Object, Attributes, Attribute
# Create a new object
new_obj = Object(
attributes=Attributes(attribute=[
Attribute(name="inetnum", value="192.168.2.0 - 192.168.2.255"),
Attribute(name="netname", value="MY-NETWORK"),
# Add more attributes...
])
)
result = client.create_object(new_obj)# Update existing object
updated_obj = Object(
attributes=Attributes(attribute=[
Attribute(name="inetnum", value="192.168.2.0 - 192.168.2.255"),
Attribute(name="netname", value="MY-UPDATED-NETWORK"),
])
)
result = client.update_object(updated_obj)# Delete object by primary key
pk = Attributes(attribute=[
Attribute(name="inetnum", value="192.168.2.0 - 192.168.2.255")
])
result = client.delete_object(pk)PyRipe supports all RIPE Database object types:
aut-num- Autonomous System Numberdomain- Domain nameinet6num- IPv6 address rangeinetnum- IPv4 address rangeroute- IPv4 routeroute6- IPv6 routeas-set- AS setfilter-set- Filter setinet-rtr- Internet routerpeering-set- Peering setroute-set- Route setrtr-set- Router set
as-block- AS blockirt- Incident Response Teamkey-cert- Key certificatemntner- Maintainerorganisation- Organizationperson- Personrole- Rolepoem- Poempoetic-form- Poetic form
The main client class for interacting with the RIPE REST API.
get_object(pk, unfiltered=False, managed_attributes=False, abuse_contact=False, resource_holder=False)- Retrieve a specific objectsearch(query, sources=[], inverse_attributes=None, include_tags=None, exclude_tags=None, type_filters=None, flags=None, managed_attributes=False, abuse_contact=False, resource_holder=False, limit=None, offset=None)- Search for objectscreate_object(obj)- Create a new objectupdate_object(obj)- Update an existing objectdelete_object(pk)- Delete an object
All API responses and requests use Pydantic models for type safety and validation:
WhoisResources- Main response containerObject- RIPE database objectAttributes- Object attributesAttribute- Individual attribute- And many more...
PyRipe provides specific exception types for different error scenarios:
from pyripe.exceptions import (
RipeRestApiError,
RipeRestApiServerError,
RipeRestApiInvalidPrimaryKeyError,
RipeRestApiUnexpectedResponseError
)
try:
result = client.search("invalid-query")
except RipeRestApiServerError as e:
print(f"Server error: {e.http_status}")
print(f"Error messages: {e.ripe_messages}")
except RipeRestApiInvalidPrimaryKeyError:
print("Invalid primary key provided")
except RipeRestApiError as e:
print(f"An error occurred: {e}")- Production:
https://rest.db.ripe.net - Test:
https://rest-test.db.ripe.net
For more information about the RIPE REST API, visit the official documentation.
- Python 3.13+
- requests >= 2.32.5
- pydantic >= 2.12.5
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and questions: