Skip to content

Commit d37a0e7

Browse files
committed
feat: initial .NET SDK for ipdata.info (v0.1.0)
0 parents  commit d37a0e7

25 files changed

Lines changed: 1112 additions & 0 deletions

‎.github/workflows/ci.yml‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-dotnet@v4
12+
with:
13+
dotnet-version: '8.0.x'
14+
- run: dotnet restore IPData.sln
15+
- run: dotnet build IPData.sln -c Release --no-restore
16+
- name: Test (incl. live smoke)
17+
run: dotnet test tests/IPDataInfo.Sdk.Tests/IPDataInfo.Sdk.Tests.csproj -c Release --no-build
18+
env:
19+
IPDATA_LIVE: "1"

‎.gitignore‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
bin/
2+
obj/
3+
*.user
4+
.vs/
5+
.idea/
6+
.env
7+
*.nupkg
8+
*.snupkg
9+
TestResults/

‎CHANGELOG.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
## [0.1.0] - 2026-07-08
4+
### Added
5+
- Initial release: `LookupAsync`, `GeoAsync`, `AsnAsync`, `BatchAsync`,
6+
`AsnDetailAsync`, `AsnWhoisHistoryAsync`, `AsnChangesAsync`, `ThreatDomainAsync`,
7+
`ThreatHashAsync`, `ThreatUrlAsync`.
8+
- `IpDataException` typed error with `StatusCode`; `IPDataClient` constructor
9+
accepting `apiKey`, `baseUrl`, `httpClient`, and `timeout`.
10+
- Multi-targets `netstandard2.0` and `net8.0`.

‎CONTRIBUTING.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Contributing
2+
3+
Thanks for considering a contribution to the ipdata.info .NET SDK.
4+
5+
## Setup
6+
7+
Requires the [.NET 8 SDK](https://dotnet.microsoft.com/download).
8+
9+
```
10+
dotnet restore IPData.sln
11+
dotnet build IPData.sln
12+
dotnet test tests/IPDataInfo.Sdk.Tests/IPDataInfo.Sdk.Tests.csproj
13+
```
14+
15+
Set `IPDATA_LIVE=1` to additionally run the live smoke test against the real
16+
`https://ipdata.info` endpoint.
17+
18+
## Guidelines
19+
20+
- Keep the public API in sync with [`docs/sdk-api-contract.md`](https://github.com/IPDataInfo/ipdata-dotnet)
21+
— the shared contract for every official ipdata.info SDK.
22+
- Models must tolerate missing/unknown JSON fields (the API omits null fields).
23+
- Add or update unit tests for any behavioral change; prefer the stub
24+
`HttpMessageHandler` in `tests/` over live network calls.
25+
- Follow conventional commits (`feat:`, `fix:`, `docs:`, `refactor:`, `test:`, `chore:`).
26+
27+
## Pull requests
28+
29+
1. Fork and branch from `main`.
30+
2. Make your change with tests.
31+
3. Ensure `dotnet build` and `dotnet test` pass locally.
32+
4. Open a PR describing the change and why it's needed.

‎IPData.sln‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IPDataInfo.Sdk", "src\IPDataInfo.Sdk\IPDataInfo.Sdk.csproj", "{A1E4B6B0-1E1A-4B2E-9C1D-000000000001}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IPDataInfo.Sdk.Tests", "tests\IPDataInfo.Sdk.Tests\IPDataInfo.Sdk.Tests.csproj", "{A1E4B6B0-1E1A-4B2E-9C1D-000000000002}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quickstart", "examples\Quickstart\Quickstart.csproj", "{A1E4B6B0-1E1A-4B2E-9C1D-000000000003}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{A1E4B6B0-1E1A-4B2E-9C1D-000000000001}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{A1E4B6B0-1E1A-4B2E-9C1D-000000000001}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{A1E4B6B0-1E1A-4B2E-9C1D-000000000001}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{A1E4B6B0-1E1A-4B2E-9C1D-000000000001}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{A1E4B6B0-1E1A-4B2E-9C1D-000000000002}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{A1E4B6B0-1E1A-4B2E-9C1D-000000000002}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{A1E4B6B0-1E1A-4B2E-9C1D-000000000002}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{A1E4B6B0-1E1A-4B2E-9C1D-000000000002}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{A1E4B6B0-1E1A-4B2E-9C1D-000000000003}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{A1E4B6B0-1E1A-4B2E-9C1D-000000000003}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{A1E4B6B0-1E1A-4B2E-9C1D-000000000003}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{A1E4B6B0-1E1A-4B2E-9C1D-000000000003}.Release|Any CPU.Build.0 = Release|Any CPU
30+
EndGlobalSection
31+
GlobalSection(SolutionProperties) = preSolution
32+
HideSolutionNode = FALSE
33+
EndGlobalSection
34+
EndGlobal

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 ipdata.info
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# IPData.info .NET SDK — Free IP Geolocation & Threat Intelligence API
2+
3+
[![NuGet](https://img.shields.io/nuget/v/IPDataInfo.Sdk.svg)](https://www.nuget.org/packages/IPDataInfo.Sdk/) [![CI](../../actions/workflows/ci.yml/badge.svg)](../../actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
4+
5+
Official .NET client for [**ipdata.info**](https://ipdata.info) — a free, fast
6+
IP geolocation, ASN, and threat-intelligence API. Look up country, city, ASN,
7+
timezone, currency, and security flags (proxy/VPN/Tor/hosting) for any IPv4 or
8+
IPv6 address. Powered by [ipdata.info](https://ipdata.info).
9+
10+
## Get a free API key
11+
12+
The public endpoint is **free — 50 requests/min, no signup, no key**. For higher
13+
rate limits and batch lookups, [**create a free API key at
14+
ipdata.info/register**](https://ipdata.info/register) and manage it in your
15+
[dashboard](https://ipdata.info/dashboard).
16+
17+
## Install
18+
19+
```
20+
dotnet add package IPDataInfo.Sdk
21+
```
22+
23+
## Quickstart
24+
25+
```csharp
26+
using IPDataInfo;
27+
28+
using var client = new IPDataClient(); // free tier; or new IPDataClient(apiKey: "KEY")
29+
30+
var info = await client.LookupAsync("8.8.8.8");
31+
Console.WriteLine($"{info.City}, {info.Country} ({info.AsnOrg})"); // Mountain View, United States (Google LLC)
32+
```
33+
34+
## Methods
35+
36+
| Method | What it returns |
37+
|--------|-----------------|
38+
| `LookupAsync(ip?)` | Full geolocation record (own IP if `ip` omitted) |
39+
| `GeoAsync(ip)` | Geo subset (city/region/country/lat/lon/tz) |
40+
| `AsnAsync(ip)` | ASN + ISP/registry for an IP |
41+
| `BatchAsync(ips)` | Many IPs at once (**requires an API key**) |
42+
| `AsnDetailAsync(n)` | ASN detail incl. prefixes |
43+
| `AsnWhoisHistoryAsync(n)` | ASN whois history |
44+
| `AsnChangesAsync()` | ASN change feed |
45+
| `ThreatDomainAsync/ThreatHashAsync/ThreatUrlAsync(x)` | Threat-intel lookup (domain / file hash / URL) |
46+
47+
Full response schema: [ipdata.info API docs](https://ipdata.info/docs) ·
48+
[SDK list](https://ipdata.info/docs/sdks).
49+
50+
## Configuration
51+
52+
```csharp
53+
new IPDataClient(
54+
apiKey: "KEY", // sent as X-Api-Key; switches to pro.ipdata.info
55+
baseUrl: "https://ipdata.info", // override the host
56+
httpClient: customHttpClient, // bring your own HttpClient (proxy, handlers, ...)
57+
timeout: TimeSpan.FromSeconds(5)); // ignored when httpClient is supplied
58+
```
59+
60+
Errors from non-2xx responses are thrown as `IPDataInfo.IpDataException` with
61+
`StatusCode` and `Message`.
62+
63+
## Rate limits
64+
65+
- Free (`ipdata.info`): 50 req/min, no key.
66+
- Paid (`pro.ipdata.info`): higher limits + `BatchAsync`, with an
67+
[API key](https://ipdata.info/register).
68+
69+
## Other SDKs
70+
71+
12 official SDKs — see the full list at
72+
[**ipdata.info/docs/sdks**](https://ipdata.info/docs/sdks): Python, Node.js, Go,
73+
PHP, Java, Rust, .NET, Kotlin, Swift, Dart, Bash, Objective-C.
74+
75+
## License
76+
77+
MIT © [ipdata.info](https://ipdata.info)

‎examples/Quickstart/Program.cs‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Quickstart example for the ipdata.info .NET SDK.
2+
// Run: dotnet run --project examples/Quickstart
3+
4+
using System;
5+
using System.Threading.Tasks;
6+
using IPDataInfo;
7+
8+
// Free tier — no API key needed. For higher limits + batch, get a free key at
9+
// https://ipdata.info/register and pass it as the apiKey argument below.
10+
using var client = new IPDataClient();
11+
12+
try
13+
{
14+
var info = await client.LookupAsync("8.8.8.8");
15+
Console.WriteLine($"{info.Ip} is in {info.City}, {info.Country} (ASN {info.Asn} — {info.AsnOrg})");
16+
17+
var threat = await client.ThreatDomainAsync("example.com");
18+
Console.WriteLine($"example.com listed as a threat: {threat.Listed}");
19+
}
20+
catch (IpDataException ex)
21+
{
22+
Console.Error.WriteLine($"ipdata request failed: {ex.StatusCode} {ex.Message}");
23+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<LangVersion>latest</LangVersion>
7+
<Nullable>enable</Nullable>
8+
<ImplicitUsings>disable</ImplicitUsings>
9+
<IsPackable>false</IsPackable>
10+
<RootNamespace>IPDataInfo.Examples.Quickstart</RootNamespace>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="../../src/IPDataInfo.Sdk/IPDataInfo.Sdk.csproj" />
15+
</ItemGroup>
16+
17+
</Project>

0 commit comments

Comments
 (0)