VigLink Developer Center - Link Monetization API

Developer Center

Link Monetization API

While the easiest and most popular way to use VigLink Convert is with the JavaScript library, links can also be monetized directly with our simple HTTP API.

Monetization API URLs documented below must not be exposed directly to users. For VigLink-monetized URLs that can be distributed publicly, see our documentation on building monetized URLs.

Request

Convert a URL to its monetized equivalent, if any.

Calls to this API are counted as “clicks” in your VigLink analytics. For this reason, an application should perform a call every time a user is about to be redirected to an external URL, even if the application has cached the response from a prior request.

URL
http://api.viglink.com/api/click
Method
GET
Parameters

Many parameters are optional, but we strongly recommend including as many parameters as possible. Any extra data you can provide will improve the quality of analytics on your VigLink dashboard.

format

For legacy reasons, format must always be provided, even though it only supports a value of txt. This requirement will be removed in a future API version.

required; string; possible values: txt

format=txt
key
Your VigLink API key, found on your account page.

required; string

key=88ac2a40e081e283ac504d1789d398ac
loc

The URL to the document containing the link being monetized. For example, if a link from http://example.com to http://amazon.com/dp/0316769487 is being affiliated, loc is http://example.com. An accurate loc value is required in your API call.

required; string; format: URL

loc=http%3A%2F%2Fexample.com
out

The URL to monetize.

required; string; format: URL

out=http%3A%2F%2Famazon.com%2Fdp%2F0316769487
cuid

An ID of your choosing that identifies the clicker, the page the link is on, a campaign or the click itself. See our CUID documentation for details.

optional; string; format: up to 32 alphanumeric characters

cuid=myid123
reaf

By default, VigLink will not modify URLs which are already affiliated. To force re-affiliation for a single URL, set reaf to true. If you’d like to force re-affiliation globally, you can make that change in your VigLink settings.

optional; boolean; default: false

reaf=true
ref

Short for “referrer”, ref is the URL of the referring document for the current page. Expanding on the example from loc, if the user came from http://othersite.com to get to http://example.com, ref is http://othersite.com.

optional; string

ref=http%3A%2F%2Fothersite.com
title

The HTML title of the page containing the link to out.

optional; string

title=My%20Blog%3A%20Check%20This%20Out%21
txt

The HTML link text of the link to out.

optional; string

txt=on%20this%20store

Response

The server will respond with one of these HTTP status codes:

200

The request was successful. The response body is a plain text URL.

If the input URL (specified by the out parameter) could be monetized, the monetized version of that URL is returned. If there is no monetized version, the original URL is returned unmodified.

400
Required parameters were missing, or their values were not valid.
503
Service is temporarily unavailable.

Example

A user arrived on your site, http://example.com, via http://othersite.com. They left your site by clicking a link to http://amazon.com/dp/0316769487.

An API request to monetize that interaction would look something like this:

$ curl -D - 'http://api.viglink.com/api/click?out=http%3A%2F%2Famazon.com%2Fdp%2F0316769487&ref=http%3A%2F%2Fothersite.com&loc=http%3A%2F%2Fexample.com&key=88ac2a40e081e283ac504d1789d398ac&format=txt'
          
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 42

http://amazon.com/dp/0316769487?tag=vig-20