Skip to content
Projets

urlquery/urlquery-api-go

Voir sur GitHub

À propos

Go client for the urlquery v2 API

Sécurité et confidentialité

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
Historique en cours
in 15 days
Historique en cours
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

urlquery-api-go

Go Reference License: MIT

The Go client for the urlquery v2 API. urlquery analyzes URLs in an isolated browser and records what they do: redirects, HTTP traffic, scripts, downloads, detections and a screenshot.

With this package you can submit URLs and wait for the reports, read and compare reports, search a year of reports, look up reputation, explore Host Profile, and manage YARA rules, watchlists and page monitors, with typed results for every field.

Documentation: https://docs.urlquery.net/docs/libraries/go · API reference

This version is for the v2 API and replaces the earlier client for the deprecated v1 API. Its calls, names and types are new.

Install

go get github.com/urlquery/urlquery-api-go

It needs Go 1.25 or later, and an API key from your urlquery.net account.

Example

package main

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

	urlquery "github.com/urlquery/urlquery-api-go"
)

func main() {
	ctx := context.Background()
	c := urlquery.New(os.Getenv("URLQUERY_APIKEY"))

	// Analyze a URL as a restricted report and wait for it.
	access := urlquery.SubmissionRequestAccessRestricted
	s, err := c.Submit(ctx, urlquery.SubmissionRequest{URL: "https://example.com/login", Access: &access})
	if err != nil {
		log.Fatal(err)
	}
	if s, err = c.WaitForSubmission(ctx, s.QueueID, 5*time.Minute); err != nil {
		log.Fatal(err)
	}

	// The full report: every HTTP transaction, script and artifact.
	r, err := c.Report(ctx, s.ReportID)
	if err != nil {
		log.Fatal(err)
	}
	for _, t := range r.HTTP {
		fmt.Println(t.Response.StatusCode, t.URL.Addr)
	}

	// Every other report that loaded the same scripts.
	for _, script := range r.Javascript.Script {
		for hit, err := range c.AllSearchResults(ctx, "javascript.script.sha256:"+script.Sha256, urlquery.SearchOptions{}) {
			if err != nil {
				log.Fatal(err)
			}
			fmt.Println(script.Sha256[:12], hit.ReportID, hit.URL.Addr)
		}
	}
}

How it behaves

  • Typed results. The models are generated from the API's OpenAPI description, so every field of every response, down to the report's transactions, scripts and artifacts, has a Go type.
  • Paging. Each list method returns one page; its All… method is an iterator over every item, following cursors for you.
  • Rate limits and retries. A call waits out a rate limit for its Retry-After, and a GET is retried after a server error or a network failure; WithMaxRetryWait bounds the waiting. Submissions are never retried once they may have been queued.
  • Waiting for an analysis. WaitForSubmission polls until the analysis is done or has failed; when it gives up, it returns the last state it saw, so you keep the queue and report IDs.
  • Errors. API errors are *APIError values with the API's error code, such as NOT_FOUND or RATE_LIMIT_EXCEEDED.
  • Hostile content. Report content comes from the analyzed sites: treat titles, scripts and downloads as untrusted data.

Contributing

Report bugs and ask for features in the issues. Pull requests are welcome: this repository is published from urlquery's main repository, so an accepted change is applied there and arrives here with the next release. models.gen.go is generated from the API description; don't edit it by hand. For other questions, write to [email protected].

go test ./...

TestLive runs against the real API when URLQUERY_E2E_APIKEY is set. Use a key of a test account: it analyzes example.com and creates, then deletes, a YARA rule, a watchlist and a page monitor.

CHANGELOG.md lists the changes in each release. Report vulnerabilities privately, as SECURITY.md describes, not in an issue.

License

MIT © urlquery.net, see LICENSE.

Explorer des projets similaires

Chargement…