> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neariq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# cURL, Ruby & Go

> Example requests in cURL, Ruby, and Go.

## cURL

```bash theme={null}
# Get business profile
curl https://app.neariq.io/api/v1/me \
  -H "X-NearIQ-Key: niq_your_key_here"

# Get recent danger alerts
curl "https://app.neariq.io/api/v1/me/alerts?severity=danger&limit=10" \
  -H "X-NearIQ-Key: niq_your_key_here"

# Register a webhook
curl -X POST https://app.neariq.io/api/v1/webhooks \
  -H "X-NearIQ-Key: niq_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://yourapp.com/hook","events":["*"],"secret":"your_secret"}'
```

## Ruby

```ruby theme={null}
require 'net/http'
require 'json'

def neariq(path, params = {})
  uri = URI("https://app.neariq.io/api/v1#{path}")
  uri.query = URI.encode_www_form(params) unless params.empty?
  req = Net::HTTP::Get.new(uri)
  req['X-NearIQ-Key'] = ENV['NEARIQ_API_KEY']
  res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |h| h.request(req) }
  JSON.parse(res.body)
end

me = neariq('/me')
puts "#{me['name']}: #{me['rating']} stars"
```

## Go

Install the official Go SDK:

```bash theme={null}
go get github.com/NearIQ/neariq-go
```

```go theme={null}
package main

import (
    "context"
    "fmt"
    "log"
    "os"

    "github.com/NearIQ/neariq-go/neariq"
)

func main() {
    client, err := neariq.NewClient(os.Getenv("NEARIQ_API_KEY"))
    if err != nil {
        log.Fatal(err)
    }

    ctx := context.Background()

    me, err := client.Me(ctx)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(value(me.Name), value(me.Rating))

    competitors, err := client.Competitors(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(competitors)

    created, err := client.CreateCompetitor(ctx, neariq.CreateCompetitorRequest{
        Name: "Apex Coffee",
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(created)

    report, err := client.Report(ctx, "report-uuid")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(value(report.Headline))

    csvText, err := client.ExportCSV(ctx, &neariq.ExportParams{
        Include: []string{"competitors", "alerts"},
        DateRange: "90d",
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(csvText)

    zipBytes, err := client.ExportAll(ctx, "90d", "")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(len(zipBytes))

    embed, err := client.CreateChartEmbed(ctx, map[string]any{
        "metrics": []string{"review_count"},
        "range": "30d",
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(embed)
}

func value[T any](v *T) T {
    if v == nil {
        var zero T
        return zero
    }
    return *v
}
```

### Go SDK method coverage

The Go client covers the current public `/api/v1` API, including `client.CreateCompetitor`, `client.Snapshots`, `client.OwnReviews`, `client.ResponseTemplates`, `client.Reviews`, `client.ExportAll`, `client.MarketDensity`, `client.MarketSaturation`, `client.MarketLeaders`, `client.MarketSignals`, `client.MarketTrends`, `client.MarketProjections`, `client.Webhooks`, `client.CreateWebhook`, `client.UpdateWebhook`, `client.DeleteWebhook`, `client.BrandMentions`, `client.KeywordSuggestions`, `client.ReviewRequests`, `client.SendReviewRequest`, `client.Leads`, `client.SocialPosts`, `client.CreateSocialPost`, `client.ListingSync`, `client.Conversations`, `client.PublishTargets`, `client.Charts`, `client.CreateChartEmbed`, `client.Tables`, `client.Ads`, `client.GenerateImage`, `client.Chat`, `client.SiteAudit`, `client.Video`, `client.CreateVideo`, `client.VoiceClones`, and `client.HiringSignals`.
