dub 0.0.3 dub: ^0.0.3 copied to clipboard
Unofficial Dub.co SDK
dub (EXPERIMENTAL) #
Dub is link management infrastructure for companies to create marketing campaigns, link sharing features, and referral programs.
For more information, please visit https://dub.co/api
Requirements #
- Dart 2.15.0+ or Flutter 2.8.0+
- Dio 5.0.0+ (https://pub.dev/packages/dio)
- JSON Serializable 6.1.5+ (https://pub.dev/packages/json_serializable)
Installation & Usage #
pub.dev #
To use the package from pub.dev, please include the following in pubspec.yaml
dependencies:
dub: 0.0.1
Github #
To use this package from Github, please include the following in pubspec.yaml
dependencies:
dub:
git:
url: https://github.com/thealphamerc/dub-dart.git
#ref: main
Local development #
To use the package from your local drive, please include the following in pubspec.yaml
dependencies:
dub:
path: /path/to/dub
Getting Started #
Please follow the installation procedure and then run the following:
import 'package:dub/dub.dart';
final api = Dub().getLinksApi();
final analyticsApi = Dub().getAnalyticsApi();
final String workspaceId = 'ws_cluuwcv0r....' // String | The ID of the workspace.
// Create a link
try {
final response = await api.createLink(
workspaceId: workspaceId!,
createLinkRequest: CreateLinkRequest(
url: 'https://www.google.com',
externalId: "12345", // Optional
),
);
print(response);
} catch on DioException (e) {
print("Exception when calling LinkAPI->createLink: $e\n");
}
// Upsert a link
// Update the link if same URL already exists or create a new link
try {
final response = await api.upsertLink(
workspaceId: workspaceId!,
createLinkRequest: CreateLinkRequest(
url: 'https://www.google.com',
externalId: "12345", // Optional
),
);
print(response);
} catch on DioException (e) {
print("Exception when calling LinkAPI->upsertLink: $e\n");
}
// Update a link
try {
final response = await api.upsertLink(
linkId: 'clv3o9p9q000au1h0mc7r6l63',
workspaceId: workspaceId!,
createLinkRequest: CreateLinkRequest(
url: 'https://www.google.com',
),
);
// Update a link by its externalId
final response2 = await api.upsertLink(
linkId: 'ext_12345',
workspaceId: workspaceId!,
createLinkRequest: CreateLinkRequest(
url: 'https://www.google.com',
),
);
print(response);
} catch on DioException (e) {
print("Exception when calling LinkAPI->upsertLink: $e\n");
}
// Retrieve the timeseries analytics for the last 7 days for a link
try {
final response = await analyticsApi.retrieveAnalytics(
linkId: 'clv3o9p9q000au1h0mc7r6l63',
workspaceId: workspaceId,
interval: '7d',
event: 'click',
groupBy: 'timeseries'
);
print(response);
} catch on DioException (e) {
print("Exception when calling AnalyticsAPI->retrieveAnalytics: $e\n");
}
Documentation for API Endpoints #
All URIs are relative to https://api.dub.co
Class | Method | HTTP request | Description |
---|---|---|---|
AnalyticsApi | retrieveAnalytics | GET /analytics | Retrieve analytics for a link, a domain, or the authenticated workspace. |
DomainsApi | addDomain | POST /domains | Add a domain |
DomainsApi | deleteDomain | DELETE /domains/{slug} | Delete a domain |
DomainsApi | listDomains | GET /domains | Retrieve a list of domains |
DomainsApi | setPrimaryDomain | POST /domains/{slug}/primary | Set a domain as primary |
DomainsApi | transferDomain | POST /domains/{slug}/transfer | Transfer a domain |
DomainsApi | updateDomain | PATCH /domains/{slug} | Update a domain |
LinksApi | bulkCreateLinks | POST /links/bulk | Bulk create links |
LinksApi | createLink | POST /links | Create a new link |
LinksApi | deleteLink | DELETE /links/{linkId} | Delete a link |
LinksApi | getLinkInfo | GET /links/info | Retrieve a link |
LinksApi | getLinks | GET /links | Retrieve a list of links |
LinksApi | getLinksCount | GET /links/count | Retrieve the number of links |
LinksApi | updateLink | PATCH /links/{linkId} | Update a link |
LinksApi | upsertLink | PUT /links/upsert | Upsert a link |
MetatagsApi | getMetatags | GET /metatags | Retrieve the metatags for a URL |
QRCodesApi | getQRCode | GET /qr | Retrieve a QR code |
TagsApi | createTag | POST /tags | Create a new tag |
TagsApi | getTags | GET /tags | Retrieve a list of tags |
TrackApi | trackCustomer | POST /track/customer | Track a customer |
TrackApi | trackLead | POST /track/lead | Track a lead |
TrackApi | trackSale | POST /track/sale | Track a sale |
WorkspacesApi | createWorkspace | POST /workspaces | Create a workspace |
WorkspacesApi | getWorkspace | GET /workspaces/{idOrSlug} | Retrieve a workspace |
WorkspacesApi | getWorkspaces | GET /workspaces | Retrieve a list of workspaces |
Documentation For Models #
- AddDomainRequest
- ClicksBrowsers
- ClicksCities
- ClicksCount
- ClicksCountries
- ClicksDevices
- ClicksOS
- ClicksReferers
- ClicksTimeseries
- ClicksTopLinks
- ClicksTopUrls
- CountryCode
- CreateLinkRequest
- CreateLinkRequestTagIds
- CreateTagRequest
- CreateWorkspaceRequest
- DeleteDomain200Response
- DeleteLink200Response
- DomainSchema
- GetLinks400Response
- GetLinks400ResponseError
- GetLinks401Response
- GetLinks401ResponseError
- GetLinks403Response
- GetLinks403ResponseError
- GetLinks404Response
- GetLinks404ResponseError
- GetLinks409Response
- GetLinks409ResponseError
- GetLinks410Response
- GetLinks410ResponseError
- GetLinks422Response
- GetLinks422ResponseError
- GetLinks429Response
- GetLinks429ResponseError
- GetLinks500Response
- GetLinks500ResponseError
- GetLinksCountGroupByParameter
- GetLinksTagIdsParameter
- GetLinksTagNamesParameter
- GetMetatags200Response
- LeadsBrowsers
- LeadsCities
- LeadsCount
- LeadsCountries
- LeadsDevices
- LeadsOS
- LeadsReferers
- LeadsTimeseries
- LeadsTopLinks
- LeadsTopUrls
- LinkGeoTargeting
- LinkSchema
- LinkSchemaGeo
- RetrieveAnalytics200Response
- SalesBrowsers
- SalesCities
- SalesCount
- SalesCountries
- SalesDevices
- SalesOS
- SalesReferers
- SalesTimeseries
- SalesTopLinks
- SalesTopUrls
- TagSchema
- TrackCustomer200Response
- TrackCustomerRequest
- TrackLead200Response
- TrackLeadRequest
- TrackSale200Response
- TrackSaleRequest
- TransferDomainRequest
- UpdateDomainRequest
- WorkspaceSchema
- WorkspaceSchemaDomainsInner
- WorkspaceSchemaUsersInner
Documentation For Authorization #
Authentication schemes defined for the API:
token #
- Type: HTTP Bearer Token authentication. You can create your token from the Dub.co dashboard.