https://github.com/zocker-160/geoloc-api
Simple HTTP API for requesting location of an IPv4
https://github.com/zocker-160/geoloc-api
Last synced: 9 months ago
JSON representation
Simple HTTP API for requesting location of an IPv4
- Host: GitHub
- URL: https://github.com/zocker-160/geoloc-api
- Owner: zocker-160
- License: agpl-3.0
- Created: 2022-08-24T17:35:31.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-01-09T19:03:47.000Z (over 2 years ago)
- Last Synced: 2024-11-09T03:39:14.309Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 43 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Geoloc-API
## Usage
### Run (binary)
- download binary from releases or compile (see Makefile in src folder)
```bash
./Geoloc-API "path/to/ip-locations.txt"
```
### Run (Docker)
- `docker build . -t geolocapi`
- `docker run -d -p 9001:9001 geolocapi`
### ENV Variables
- `GEOAPI_RAM_OPT`: enables low memory mode if set to `"1"`
- `GEOAPI_PORT`: port HTTP server will listen to
### Request
#### CURL
```bash
curl -X POST -d "" http://:/
```
#### PHP
```php
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => ""
)
);
$context = stream_context_create($opts);
$result = file_get_contents('http://:/', false, $context);
echo $result;
?>
```
### Endpoints
- `POST /country`
- `POST /coords`
- `POST /all/json` example respone:
```json
{
"Range": {
"StartIP": 3758088960,
"EndIP": 3758089215
},
"Country": "Indonesia",
"Location": {
"Latitude": -0.22019,
"Longitude": 100.63078
}
}
```