package
0.0.0-20240612102834-1fd701ef7799
Repository: https://github.com/digiseg-labs/api-client-go.git
Documentation: pkg.go.dev

# README

Go API client for openapi

Digiseg API documentation

Introduction

This API let you harness the power of Digisegs powerful and tracking-free segmentation engine.

Audiences by Digiseg are available in 50+ countries, probablistically mapping neighborhood characteristics to the IP addresses observed on the internet - Household targeting & measurement for the post-cookie world.

Developer SDKs

In addition to using these APIs directly through any HTTP client, we provide a set of API client SDKs for popular programming languages:

Audience taxonomy

Digiseg audiences are grouped into private and business audiences. In each group there are categories that then contain the audiences. The API endpoints that communicate audiences and household characteristics, audience codes are being used.

The following table can be used as a reference for audience codes. Note that Digiseg will at times update names of audiences for purposes of internationalization, clarity or other such purposes - but the codes will remain as-is and should be considered a stable point of reference for the audience.

GroupCategoryAudience CodeAudience Name
privatehome_typea1Apartment
a2House
savingsb1No Savings
b2Smaller Savings
b3Larger Savings
lifecyclec1Young couples and singles
c2Early family life
c3Middle-aged families
c4Mature families
c5Pensioners / Retirees
carsd1No cars
d21 car
d32 or more cars
childrene1No children
e21 child
e32 or more children
educationf1Basic
f2Medium
f3Higher
neighbourhood_typeg1Countryside
g2Village
g3Suburban
g4City
incomeh1Lowest 20%
h2Lowest 20-40%
h3Middle 40-60%
h4Highest 60-80%
h5Top 20%
home_ownershipj1Rent
j2Own
building_agek1Pre 1945
k21945-1989
k31990 until today
living_spacel1Small
l2Medium
l3Large
tech_leveln1Basic
n2Medium
n3High
businesssizeba1Small Business
ba2Medium Business
ba3Larger Business

There is also an interactive Audience builder which lets you discover the targeting reach and power of combining various household characteristics into composite audiences.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 1.0.0
  • Package version: 1.0.0
  • Generator version: 7.6.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import openapi "github.com/digiseg-labs/api-client-go"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value openapi.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value openapi.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using openapi.ContextOperationServerIndices and openapi.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://api.digiseg.net

ClassMethodHTTP requestDescription
AccountsAPICreateUserInAccountPost /accounts/{account_id}/usersCreate user
AccountsAPIDeleteAccountLogoDelete /accounts/{account_id}/assets/logoDelete account logo
AccountsAPIGetAccountByIdGet /accounts/{account_id}Get account
AccountsAPIGetAccountLogoGet /accounts/{account_id}/assets/logoGet account logo
AccountsAPIGetAccountSubscriptionByIdGet /accounts/{account_id}/subscriptions/{subscription_id}Get account subscription
AccountsAPIGetAccountSubscriptionsGet /accounts/{account_id}/subscriptionsGet account subscriptions summary
AccountsAPIListApiKeysByAccountIdGet /accounts/{account_id}/apikeysList API keys for account
AccountsAPIListUsersByAccountIdGet /accounts/{account_id}/usersList users for account
AccountsAPIUpdateAccountByIdPut /accounts/{account_id}Update account
AccountsAPIUploadAccountLogoPut /accounts/{account_id}/assets/logoUpload account logo
AudiencesAPIResolveAudiencesOfClientGet /audiencesGet audiences of the API client
AudiencesAPIResolveAudiencesOfMultiplePost /audiencesGet audiences for multiple IP addresses
AudiencesAPIResolveAudiencesOfSingleGet /audiences/{user_ip}Get audiences for a given IP address
AuthAPICreateAccessTokenPost /auth/tokenAuthenticate and create access token
AuthAPICreateApiKeyPost /users/{user_id}/apikeysCreate API key
AuthAPIDeleteApiKeyByIdDelete /users/{user_id}/apikeys/{key_id}Delete API key
AuthAPIGetApiKeyByIdGet /users/{user_id}/apikeys/{key_id}Get API key
AuthAPIListApiKeysByAccountIdGet /accounts/{account_id}/apikeysList API keys for account
AuthAPIListApiKeysByUserIdGet /users/{user_id}/apikeysList API keys for user
AuthAPIUpdateApiKeyByIdPut /users/{user_id}/apikeys/{key_id}Update API key
MeasurementClientsAPICreateMeasurementClientPost /measurement/clientsCreate measurement client
MeasurementClientsAPIDeleteClientLogoDelete /measurement/clients/{client_id}/assets/logoDelete measurement client logo
MeasurementClientsAPIDeleteMeasurementClientByIdDelete /measurement/clients/{client_id}Delete measurement client
MeasurementClientsAPIGetClientLogoGet /measurement/clients/{client_id}/assets/logoGet measurement client logo
MeasurementClientsAPIGetMeasurementClientByIdGet /measurement/clients/{client_id}Get measurement client
MeasurementClientsAPIListMeasurementClientsGet /measurement/clientsList measurement clients
MeasurementClientsAPIUpdateMeasurementClientByIdPut /measurement/clients/{client_id}Update measurement client
MeasurementClientsAPIUploadClientLogoPut /measurement/clients/{client_id}/assets/logoUpload measurement client logo
MeasurementLabelsAPIListMeasurementLabelsGet /measurement/labelsList measurement labels
PopulationsAPIGetPopuplationByKeyGet /populations/{category_key}/{population_key}Get Population by key
PopulationsAPIListPopuplationsGet /populations/{category_key}List populations of category
StudiesAPICreateStudyPost /studiesCreate study
StudiesAPIDeleteStudyBannerImageDelete /studies/{study_id}/assets/banner_imageDelete study banner image logo
StudiesAPIDeleteStudyByIdDelete /studies/{study_id}Delete study
StudiesAPIGetStudyBannerImageGet /studies/{study_id}/assets/banner_imageGet study banner image
StudiesAPIGetStudyByIdGet /studies/{study_id}Get study
StudiesAPIListStudiesGet /studiesList studies
StudiesAPIQueryStudyAudienceStatsGet /studies/{study_id}/stats/audiencesAudience statistics for study
StudiesAPIQueryStudyCountryStatsGet /studies/{study_id}/stats/countriesCountry statistics for study
StudiesAPIQueryStudyFrequencyStatsGet /studies/{study_id}/stats/frequenciesFrequency statistics for study
StudiesAPIQueryStudyTimingStatsGet /studies/{study_id}/stats/timingTiming statistics for study
StudiesAPIUpdateStudyByIdPut /studies/{study_id}Update study
StudiesAPIUploadStudyBannerImagePut /studies/{study_id}/assets/banner_imageUpload study banner image
SubscriptionsAPIGetAccountSubscriptionByIdGet /accounts/{account_id}/subscriptions/{subscription_id}Get account subscription
SubscriptionsAPIGetAccountSubscriptionsGet /accounts/{account_id}/subscriptionsGet account subscriptions summary
SubscriptionsAPIListSubscriptionPlansGet /subscription_plansList subscription plans
UsageAPIListAudienceDataDailyUsageGet /usage/audience_data/dailyList daily usage of Audience Data
UsageAPIListAudienceDataMonthlyUsageGet /usage/audience_data/monthlyList monthly usage of Audience Data
UsageAPIListAudienceDataRealtimeUsageGet /usage/audience_data/realtimeList realtime usage of Audience Data
UsersAPICreateApiKeyPost /users/{user_id}/apikeysCreate API key
UsersAPICreateUserInAccountPost /accounts/{account_id}/usersCreate user
UsersAPIDeleteApiKeyByIdDelete /users/{user_id}/apikeys/{key_id}Delete API key
UsersAPIDeleteUserAvatarDelete /users/{user_id}/assets/avatarDelete user avatar
UsersAPIDeleteUserByIdDelete /users/{user_id}Delete user
UsersAPIGetApiKeyByIdGet /users/{user_id}/apikeys/{key_id}Get API key
UsersAPIGetCurrentUserGet /userGet current user
UsersAPIGetUserAvatarGet /users/{user_id}/assets/avatarGet user avatar
UsersAPIGetUserByIdGet /users/{user_id}Get user
UsersAPIListApiKeysByUserIdGet /users/{user_id}/apikeysList API keys for user
UsersAPIListUsersByAccountIdGet /accounts/{account_id}/usersList users for account
UsersAPIUpdateApiKeyByIdPut /users/{user_id}/apikeys/{key_id}Update API key
UsersAPIUpdateUserByIdPut /users/{user_id}Update user
UsersAPIUploadUserAvatarPut /users/{user_id}/assets/avatarUpload user avatar

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

bearerAuth

  • Type: HTTP Bearer token authentication

Example

auth := context.WithValue(context.Background(), openapi.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)

apiKeyHeaderAuth

  • Type: API key
  • API key parameter name: X-API-KEY
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: X-API-KEY and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"X-API-KEY": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

apiKeyQueryParamAuth

  • Type: API key
  • API key parameter name: api_key
  • Location: URL query string

Note, each API key must be added to a map of map[string]APIKey where the key is: api_key and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"api_key": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

oAuth

  • Type: OAuth
  • Flow: password
  • Authorization URL:
  • Scopes: N/A

Example

auth := context.WithValue(context.Background(), openapi.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)

Or via OAuth2 module to automatically refresh tokens and perform user authentication.

import "golang.org/x/oauth2"

/* Perform OAuth2 round trip request and obtain a token */

tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, openapi.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

[email protected]