{"id":13767272,"url":"https://github.com/D4-project/IPASN-History","last_synced_at":"2025-05-10T22:31:42.209Z","repository":{"id":42489989,"uuid":"142176365","full_name":"D4-project/IPASN-History","owner":"D4-project","description":"IP ASN History to find ASN announcing an IP and the closest prefix announcing it at a specific date","archived":false,"fork":false,"pushed_at":"2024-10-02T09:45:56.000Z","size":830,"stargazers_count":91,"open_issues_count":6,"forks_count":12,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-11-17T02:34:32.752Z","etag":null,"topics":["d4-project","historical-data","ip-address","ip-asn-history","ip-whois","security-tools"],"latest_commit_sha":null,"homepage":"https://www.d4-project.org/open%20source/asn/history/2019/01/09/IP-ASN-History.html","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/D4-project.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-24T15:14:19.000Z","updated_at":"2024-10-02T09:46:00.000Z","dependencies_parsed_at":"2024-07-06T16:44:15.234Z","dependency_job_id":null,"html_url":"https://github.com/D4-project/IPASN-History","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/D4-project%2FIPASN-History","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/D4-project%2FIPASN-History/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/D4-project%2FIPASN-History/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/D4-project%2FIPASN-History/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/D4-project","download_url":"https://codeload.github.com/D4-project/IPASN-History/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253492529,"owners_count":21916959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["d4-project","historical-data","ip-address","ip-asn-history","ip-whois","security-tools"],"created_at":"2024-08-03T16:01:06.874Z","updated_at":"2025-05-10T22:31:38.881Z","avatar_url":"https://github.com/D4-project.png","language":"Python","funding_links":[],"categories":["Online"],"sub_categories":[],"readme":"# IP ASN History\n\nIP ASN History is an open source project to figure out the ASN announcing an IP\nand the closest prefix announcing it at a specific date.\n\nThe default currently loads announces from [CAIDA](http://data.caida.org/datasets/routing/)\nalso [RIPE dumps](https://www.ripe.net/analyse/internet-measurements/routing-information-service-ris/ris-raw-data) in MRT format.\n\nIP ASN History is a complete open source project to run your own server locally.\n\nIf you don't want to run your own server, there is a [public API](https://www.d4-project.org/open%20source/asn/history/2019/01/09/IP-ASN-History.html) operated by CIRCL.\n\n# Python client\n\nSee the [PyIPASNHistory repository](https://github.com/D4-project/pyipasnhistory)\n\n# API\n\nThe REST API has two entry points:\n\n* `/meta` (GET): returns meta informations about the information currently stored in the database\n\n\t```json\n\t{\n\t  \"sources\": [\n\t    \"caida\"\n\t  ],\n\t  \"expected_interval\": {\n\t    \"first\": \"2018-05-12\",\n\t    \"last\": \"2018-11-08\"\n\t  },\n\t  \"cached_dates\": {\n\t    \"caida\": {\n\t      \"v4\": {\n\t\t\"cached\": [\n\t\t  \"2018-04-26T12:00:00\",\n\t\t  \"2018-04-27T12:00:00\",\n\t\t\t  //...\n\t\t  \"2018-11-05T12:00:00\",\n\t\t  \"2018-11-06T12:00:00\"\n\t\t],\n\t\t\"missing\": [\n\t\t  \"2018-11-07\"\n\t\t],\n\t\t\"percent\": 99.44444444444444\n\t      },\n\t      \"v6\": {\n\t\t\"cached\": [\n\t\t  \"2018-04-26T12:00:00\",\n\t\t  \"2018-04-27T12:00:00\",\n\t\t\t  //...\n\t\t  \"2018-11-06T12:00:00\",\n\t\t  \"2018-11-07T12:00:00\"\n\t\t],\n\t\t\"missing\": [],\n\t\t\"percent\": 100.0\n\t      }\n\t    }\n\t  }\n\t}\n\t```\n\n**Note**: the percentage will help 3rd party component to decide if they should query the service now or wait.\n\t\t  It is expected to miss a few days and probably not important.\n\n* **`/` (POST/GET)**: Runs a query. (if you want to resolve more than 1000 IPs, use `mass_cache` and `mass_query`)\n\n    **Parameters**:\n\n\t* **ip**: (required) IP to lookup\n\t* **source**: (optional) Source to query (defaults to 'caida') - currently, only caida is supported\n\t* **address_family**: (optional) v4 or v6 (defaults to v4)\n\t* **date**: (optional) Exact date to lookup (defaults to most recent available)\n\t* **first**: (optional) First date in the interval\n\t* **last**: (optional) Last date in the interval\n\t* **precision_delta**: (optional) Max delta allowed between the date queried and the one we have in the database. Expects a dictionary to pass to timedelta.\n\t\t\t Example: {days=1, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0}\n\n    **Response**:\n\n\t```json\n\t{\n\t  \"meta\": {\n\t    \"source\": \"caida\",\n\t    \"ip_version\": \"v4\",\n\t    \"ip\": \"146.185.222.49\"\n\t  },\n\t  \"error\": \"Optional, only if there was an error\",\n\t  \"info\": \"Optional, informational message if needed\",\n\t  \"response\": {\n\t    \"2018-11-01T12:00:00\": {\n\t      \"asn\": \"44050\",\n\t      \"prefix\": \"146.185.222.0/24\"\n\t    },\n\t    \"2018-11-02T16:00:00\": {\n\t      \"asn\": \"44050\",\n\t      \"prefix\": \"146.185.222.0/24\"\n\t    },\n\t    \"2018-11-03T12:00:00\": {\n\t      \"asn\": \"44050\",\n\t      \"prefix\": \"146.185.222.0/24\"\n\t    },\n\t    \"2018-11-04T12:00:00\": {\n\t      \"asn\": \"44050\",\n\t      \"prefix\": \"146.185.222.0/24\"\n\t    },\n\t    \"2018-11-05T12:00:00\": {\n\t      \"asn\": \"44050\",\n\t      \"prefix\": \"146.185.222.0/24\"\n\t    },\n\t    \"2018-11-06T12:00:00\": {\n\t      \"asn\": \"44050\",\n\t      \"prefix\": \"146.185.222.0/24\"\n\t    }\n\t  }\n\t}\n\t```\n\n\n    **Curl examples**:\n\n    It works fine for single requests, if you have batches of IPs to lookup, use the python API and `mass_cache` `mass_query`.\n\n    ```bash\n    curl https://bgpranking-ng.circl.lu/ipasn_history/?ip=8.8.8.8\n    curl \"https://bgpranking-ng.circl.lu/ipasn_history/?ip=2001:db8:a0b:12f0::1\u0026address_family=v6\"\n    ```\n\n    **Note**: The date returned may differ from the one queried: the system will figure out the closest available date to the one queried.\n\n* **`/mass_cache` (POST)**: Caches a lot of queries at once, don't wait for the lookup.\n\n    **Parameters**: A list of dictionaries with the same parameters as the default query.\n\n    **Response**: A list of queries that IPASN History wasn't able to process.\n\n    **Note**: Use this path when you have lots of query to run and (\u003e1000) in order to resolve all of them at once.\n\n* **`/mass_query` (POST)**: Caches a lot of queries at once. Either wait for the lookup to be done, or pick the data from cache.\n\n    **Parameters**: A list of dictionaries with the same parameters as the default query.\n\n    **Response**: A list of responses as the default query.\n\n    **Note**: Use this path when you have lots of query to run and (\u003e1000) in order to resolve all of them at once.\n\n* **`/asn_meta` (POST)**: Returns meta informations about an ASN\n\n    **Parameters**: A list of dictionaries with the same parameters as the default query.\n\n    **Response**\n\n    ```json\n    {\n      \"meta\": {\n      \"address_family\": \"v4\",\n      \"asn\": \"137342\",\n      \"source\": \"caida\"\n      },\n      \"response\": {\n        \"2019-01-01T12:00:00\": {\n          \"137342\": {\n            \"ipcount\": \"512\",\n            \"prefixes\": [\n              \"180.214.250.0/24\",\n              \"103.113.3.0/24\"\n            ]\n          }\n        }\n      }\n    }\n    ```\n\n\n# Installation\n\n**IMPORTANT**: Use [poetry](https://github.com/python-poetry/poetry#installation)\n\n**NOTE**: Yes, it requires python3.8+. No, it will never support anything older.\n\n## Install redis\n\n```bash\ngit clone https://github.com/antirez/redis.git\ncd redis\ngit checkout 7.0\nmake\nmake test\ncd ..\n```\n\n**Note**: If it fails, have a look at [the documentation](https://github.com/redis/redis#building-redis).\n\n## Install kvrocks\n\n```bash\ngit clone https://github.com/KvrocksLabs/kvrocks.git\ncd kvrocks\ngit checkout 2.5\n./x.py build\ncd ..\n```\n\n**Note**: If it fails, have a look at [the documentation](https://github.com/KvrocksLabs/kvrocks#building-kvrocks).\n\n## Install \u0026 run IP ASN History\n\n```bash\ngit clone https://github.com/D4-project/IPASN-History.git\ncd IPASN-History\npoetry install\necho IPASNHISTORY_HOME=\"'`pwd`'\" \u003e .env\npoetry shell\nstart\n```\n\n## Shutdown IP ASN History\n\n```bash\nstop\n```\n\n# (Optional) Build \u0026 install bgpdumpy, required to process dumps from RIPE\n\n```bash\nsudo apt install ca-certificates gcc make autoconf libbz2-dev zlib1g-dev libffi-dev\npoetry install -E ripe\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FD4-project%2FIPASN-History","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FD4-project%2FIPASN-History","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FD4-project%2FIPASN-History/lists"}