This project provides a client library for accessing the Adobe Analytics API 2.0.
Use the standard Go tool chain to use this library in your project.
Example:
go get -u github.com/adobe/aa-client-go
Create a new Analytics client with a http.DefaultClient
.
client, err := analytics.NewClient(&analytics.Config{
BaseURL: "https://analytics.adobe.io/api",
ClientID: "<CLIENT-ID>",
OrgID: "<ORG-ID>",
AccessToken: "<ACCESS-TOKEN>",
CompanyID: "<COMPANY-ID>",
})
Use specific API endpoint. For example, get all available metrics.
metrics, err := client.Metrics.GetAll("<ReportSuiteID>", "en_US", false, []string{})
See examples for more information about using the various API endpoints.
Use ims-go to get an authentication token.
client, err := ims.NewClient(&ims.ClientConfig{
URL: "https://ims-na1.adobelogin.com",
})
resp, err := client.ExchangeJWT(&ims.ExchangeJWTRequest{
Expiration: time.Now().Add(12 * time.Hour),
PrivateKey: []byte("<PRIVATE-KEY>"),
Issuer: "<ORG-ID>",
Subject: "<TECHNICAL-ACCOUNT-ID>",
ClientID: "<CLIENT-ID>",
ClientSecret: "<CLIENT-SECRET>",
MetaScope: []ims.MetaScope{ims.MetaScopeAnalyticsBulkIngest},
})
accessToken := resp.AccessToken
To handle 429
response status codes (returned if the API rate limit is hit), a HTTP client with retry/backoff like go-retryablehttp can be used.
See the examples/utils/utils.go for an example of a custom rate limit policy.
retryClient := retryablehttp.NewClient()
retryClient.RetryMax = 10
retryClient.CheckRetry = rateLimitPolicy
client, err := analytics.NewClient(&analytics.Config{
HTTPClient: retryClient.StandardClient(),
BaseURL: "https://analytics.adobe.io/api",
ClientID: "<CLIENT-ID>",
OrgID: "<ORG-ID>",
AccessToken: "<ACCESS-TOKEN>",
CompanyID: "<COMPANY-ID>",
})
The module provides a Makefile
with following targets.
all
- Runsfmt
,vet
,lint
andtest
.fmt
- Formats all code.
Runsgo fmt ./...
vet
- Vets all code.
Runsgo vet -all ./...
lint
- Lints all code.
Runsgolint ./...
test
- Runs the test of theanalytics
package.
Runsgo test ./analytics -cover
coverage
- Runs the tests of theanalytics
package and opens the coverage report.
Runsgo test -coverprofile=coverage.out ./analytics & go tool cover -html=coverage.out
A specific target can be executed by running the following command (Linux, macOS).
make [target]
Windows users can simply bypass make
and run the plain commands as indicated above or install make
via GNUWin32, Chocolatey or Windows Subsystem for Linux.
Contributions are welcome! Read the Contributing Guide for more information.
This project is licensed under the Apache 2.0 License. See LICENSE for more information.