Skip to content

Commit 106b1c8

Browse files
committed
Update README.md with Greip Go Library information
1 parent 24e0e29 commit 106b1c8

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Greip Go Library
2+
3+
The Greip Go library allows you to easily interact with the Greip API to access a variety of services, including IP geolocation, threat intelligence, email validation, and more.
4+
5+
[Report Issue](https://github.com/Greipio/go/issues/new) ·
6+
[Request Feature](https://github.com/Greipio/go/discussions/new?category=ideas)
7+
· [Greip Website](https://greip.io/) · [Documentation](https://docs.greip.io/)
8+
9+
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/Greipio/go?color=green&label=Minified%20size&logo=github)
10+
  
11+
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/apache-2-0)
12+
  
13+
![API Status](https://img.shields.io/website?down_color=orange&down_message=down&label=API%20status&up_color=green&up_message=up&url=https%3A%2F%2Fgreipapi.com)
14+
15+
---
16+
17+
## Installation
18+
19+
You can install the Greip library by running:
20+
21+
```bash
22+
go get github.com/Greipio/go
23+
```
24+
25+
## Usage
26+
27+
To use the Greip library, first import the package and initialize the Greip instance with your API token. Here’s a basic example:
28+
29+
```go
30+
package main
31+
32+
import (
33+
"fmt"
34+
"github.com/Greipio/go"
35+
)
36+
37+
func main() {
38+
// Initialize the Greip instance with your API token
39+
greipInstance := greip.NewGreip("YOUR_API_TOKEN")
40+
41+
// Example: Lookup IP information
42+
response, err := greipInstance.Lookup("1.1.1.1")
43+
if err != nil {
44+
fmt.Println("Error:", err)
45+
return
46+
}
47+
fmt.Println(response.IP, response.ContinentName, response.City)
48+
}
49+
```
50+
51+
## Methods
52+
53+
The Greip library provides various methods to interact with the API:
54+
55+
- **Lookup(ip string, params []string, lang ...string)**: Get geolocation information about an IP address.
56+
- **Threats(ip string)**: Get threat intelligence related to an IP address.
57+
- **BulkLookup(ips []string, params []string, lang ...string)**: Get geolocation information for multiple IP addresses.
58+
- **Country(countryCode string, params []string, lang ...string)**: Get information about a country by its code.
59+
- **Profanity(text string)**: Check if a given text contains profanity.
60+
- **ASN(asn string)**: Get information about an ASN (Autonomous System Number).
61+
- **Email(email string)**: Validate an email address.
62+
- Phone(phone string, countryCode string): Validate or lookup a phone number.
63+
- **IBAN(iban string)**: Validate or lookup an IBAN number.
64+
- **Payment(data map[string]interface{})**: Check if a payment transaction is fraudulent.
65+
66+
## Example of Method Usage
67+
68+
```go
69+
// Lookup country information
70+
countryInfo, err := greipInstance.Country("US")
71+
if err != nil {
72+
fmt.Println("Error:", err)
73+
return
74+
}
75+
fmt.Println(countryInfo.CountryName, countryInfo.Population)
76+
```
77+
78+
## Development Mode
79+
80+
If you need to test the integration without affecting your subscription usage, you can set the test attribute to true when initializing the Greip instance:
81+
82+
```go
83+
greipInstance := greip.NewGreip("YOUR_API_TOKEN", true)
84+
```
85+
86+
> [!WARNING]
87+
> Enabling the test mode returns fake data. **Do not use it in production**.
88+
89+
## Error Handling
90+
91+
The library returns error for invalid parameters and request-related issues. Here’s an example of handling errors:
92+
93+
```go
94+
response, err := greipInstance.Lookup("INVALID_IP")
95+
if err != nil {
96+
fmt.Println("Error:", err)
97+
return
98+
}
99+
fmt.Println(response)
100+
```
101+
102+
## Contributing
103+
104+
Contributions are welcome! Please submit a pull request or open an issue for any improvements or bugs.
105+
106+
## License
107+
108+
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

0 commit comments

Comments
 (0)