Peeringdb
PeeringDB API client for fetching prefix information.
PeeringDBPrefixInfo
Bases: BaseModel
Prefix information from PeeringDB for a given ASN.
Attributes:
| Name | Type | Description |
|---|---|---|
asn |
int
|
The Autonomous System Number |
prefixes4 |
int | None
|
Number of IPv4 prefixes announced, or None if not available |
prefixes6 |
int | None
|
Number of IPv6 prefixes announced, or None if not available |
name |
str | None
|
Network name from PeeringDB, or None if not available |
Source code in gso/services/peeringdb.py
_parse_429_wait_time(response, fallback_wait)
Parse wait time from a 429 rate limit response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Response
|
The 429 response from PeeringDB |
required |
fallback_wait
|
int
|
Fallback wait time in seconds if not parseable |
required |
Returns:
| Type | Description |
|---|---|
int
|
Wait time in seconds. |
Source code in gso/services/peeringdb.py
create_session()
Create a requests session with retry logic and timeout.
Returns:
| Type | Description |
|---|---|
Session
|
A configured requests.Session with retry and timeout defaults. |
Source code in gso/services/peeringdb.py
fetch_prefix_info(asn, session=None)
Fetch prefix information for a given ASN from PeeringDB.
Handles HTTP 429 rate limiting with automatic retries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asn
|
int
|
The Autonomous System Number to query |
required |
session
|
Session | None
|
Optional requests session. If None, a new session will be created. |
None
|
Returns:
| Type | Description |
|---|---|
PeeringDBPrefixInfo | None
|
PeeringDBPrefixInfo if the ASN is found, None otherwise. |
Raises:
| Type | Description |
|---|---|
RequestException
|
If the API request fails after retries. |
Source code in gso/services/peeringdb.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |