References

Overview

The Fanmiles Graph API provides an easy to use query language and a runtime environment to fulfil those queries. The query language is based on GraphQL which gives clients the power to ask for exactly what they need and nothing more. The following sections explain how the Fanmiles API query language can be used to obtain offer data and reward Fanmiles users.

Get more information about GraphQL and its concepts at: http://graphql.org/learn/
Find server side frameworks for different languages at: http://graphql.org/code/

Queries

The Graph Query Language is at its simplest about asking for specific fields on objects. The query has exactly the same shape as its response. Queries are done using GET requests. It is also possible to combine multiple queries in one single GET request where each query is executed in parallel.

Offers Query

The offers query responds with currently active earn and reward offers which were created through AdFan. Expired or upcoming offers are not part of the response of the query.

Query Examples

Simple offer query

Open Query in Graph Explorer

Offer query with modifiers

Open Query in Graph Explorer

Mutations

Per convention mutations are used to modify server-side data using POST requests.Technically queries could also cause data writes but it is not recommended to use GET requests to modify data. Another difference to a query is that mutation fields run in series, one after the other while query fields are executed in parallel. The Fanmiles Graph API provides the following mutations:

Reward Mutation

The reward mutation allows partners to give an amount of Fanmiles to a user holding a valid Fanmiles ID. The Fanmiles ID should be obtained using Fanmiles Connect. This operation must be performed on the server side using an app secret. It is not permitted to perform this request from an insecure application like a browser.

Security Considerations

To secure the data which is transmitted it is required to use SSL (TLS) encryption for allPOST requests send to the Graph API. Make sure to use HTTPS in the Graph API URL as following: https://graph.fanmiles.com

Using the rewardWithApp mutation requires to use the basic authentication scheme, so that the sender of a request can be verified. The  header of a request needs to beset as following:

Mutation Example

Developer Support

Contact Fanmiles Developer Support for further questions. We are happy to receive your inputs and discuss implementation ideas. Please contact us via developers@fanmiles.com.

Did this answer your question?