Skip to content

Instantly share code, notes, and snippets.

@westdavidr
Last active May 7, 2022 15:41
Show Gist options
  • Save westdavidr/c8890e46a8f06b92df85 to your computer and use it in GitHub Desktop.
Save westdavidr/c8890e46a8f06b92df85 to your computer and use it in GitHub Desktop.
Young Living API reference

##API URLS


##Authentication

To obtain a token, issue a request to POST https://youngliving.com/api/accounts/token

  • The request must be a HTTP POST request.
  • The request must include a Content-Type header with the value of application/json.
  • The body of the request must in JSON format with memberId and password.

Request body

{
    "memberId": "",
    "password": ""
}

Example request

POST /api/accounts/token HTTP/1.1
Host: youngliving.com
Content-Type: application/json

{
    "memberId": "123456",
    "password": "sosecret"
}

##Organization Base URL: https://youngliving.com/vo.dlv.api/downline ###Endpoints

  • GET /children/user/{periodid}
  • GET /children/member_id/{periodid}
  • GET /detail/user/{periodid}
  • GET /detail/{memberid}/{periodid}

###Examples

  • (0 can be used in place of {periodid} for current period)

####Get downline for authorized user. Example Request:

GET
https://youngliving.com/vo.dlv.api/downline/children/user/405

Example Response:

{
	"customerid": "1449977",
	"currentperiodid": 406,
	"periodid": 405,
	"chartstartperiod": 398,
	"chartendperiod": 405,
	"totalchildren": 74,
	"legs": [ ]
}

####Get downline for specific user Example Request:

GET
https://youngliving.com/vo.dlv.api/downline/children/1223344/405

Example Response:

{
	"customerid": 1223344,
	"currentperiodid": 406,
	"periodid": 405,
	"chartstartperiod": 398,
	"chartendperiod": 405,
	"totalchildren": 15,
	"legs": [ ]
}

####Get details for authorized user. Example Request:

GET 
https://youngliving.com/vo.dlv.api/downline/detail/user/405

Example Response:

{
	"customerid": 123456,
	"name": "BLOW, JOE",
	"customertype": 2,
	"email": "test@example.com",
	"mainphone": "1234567891",
	"datesignedup": "5/1/2013 12:27:52 PM",
	"dateactivated": "5/1/2013 12:27:52 PM",
	"onhold": false,
	"activitystatusid": 1,
	"holdreason": "",
	"avatarimage": "",
	"volume": { },
	"rank": { },
	"address": { },
	"autoship": { },
	"sponsor": { },
	"enroller": { }
}

####Get details for a specific user. Example Request:

GET 
https://youngliving.com/vo.dlv.api/downline/detail/user/405

Example Response:

{
	"customerid": 1223344,
	"name": "MEMBER, COOL",
	"customertype": 2,
	"email": "test@example.net",
	"mainphone": "1234567891",
	"datesignedup": "11/16/2013 12:19:32 PM",
	"dateactivated": "11/16/2013 12:19:32 PM",
	"onhold": false,
	"activitystatusid": 1,
	"holdreason": "",
	"avatarimage": "",
	"volume": { },
	"rank": { },
	"address": { },
	"autoship": { },
	"sponsor": { },
	"enroller": { },
	"sponsorpath": [ ]
}

##Commission Base URL: https://youngliving.com/vo.dlv.api/commission ###Endpoints

  • GET: /check/summary/{periodid}
  • GET: /check/unilevel/{periodid}/{levelnum}
  • GET: /history/{periodid}

###Examples

  • (0 can be used in place of {periodid} for current period)

####Get commission check summary for a specific commission period. Example Request:

GET
https://youngliving.com/vo.dlv.api/commission/check/summary/405

Example Result:

{
  "customerid":"123456",
  "checkid":"12345678",
  "checkdate":"11/17/2014",
  "periodid":"405",
  "checktotal":"314.39",
  "totalcommission":"317.39",
  "currencyunit":"USD",
  "dgyf":"0",
  "paidasrankid":2,
  "maxrankid":2,
  "volume":{
    "ogv":4635.5,
    "pv":290.25,
    "pgv":4635.5
  },
  "retail":{
    "commission":"11.84"
  },
  "unilevel":{
    "commission":"229.71",
    "levels":[
      {
        "levelnum":1,
        "commission":"$142.83"
      },
      {
        "levelnum":2,
        "commission":"$63.49"
      },
      {
        "levelnum":3,
        "commission":"$23.39"
      }
    ]
  },
  "faststart":{
    "commission":"75.84",
    "levels":[
      {
        "levelnum":1,
        "commission":"$8.44"
      },
      {
        "levelnum":2,
        "commission":"$67.40"
      }
    ]
  },
  "personalgen":{
    "commission":"0"
  },
  "generations":{
    "commission":"0"
  },
  "risingstar":{
    "commission":"0"
  },
  "leadership":{
    "commission":"0"
  },
  "diamondexpress":{
    "commission":"0"
  },
  "starterkit":{
    "commission":"0"
  },
  "adjustments":{
    "total":"-3",
    "items":[
      {
        "description":"Maintenance Fee",
        "amount":"-3",
        "commledgertypeid":2
      }
    ]
  }
}

#####Get commission check details for a specific level in a commission period. Example Request:

GET
https://youngliving.com/vo.dlv.api/commission/check/unilevel/405/1

Example Result:

{
  "customerid":123456,
  "periodid":406,
  "commissionvolume":1785,
  "percentage":8,
  "commissionearned":"$142.83",
  "unilevel":{
    "levels":[
      {
        "membernum":123445,
        "membername":"MEMBER, COOL",
        "commissionvolume":75.25,
        "percentage":8.0,
        "commissionsearned":6.02
      },
      ...
    ]
  }
}

#####Get commission check details for a specific level in a commission period. Example Request:

GET
https://youngliving.com/vo.dlv.api/commission/history/405

Example Result:

{
  "customerid":1449977,
  "checks":[
    {
      "periodid":405,
      "checknumber":"12345678",
      "checkdate":"11/17/2014",
      "amount":317.39,
      "amountformatted":"$317.39",
      "currency":"USD"
    },
    ...
  ]
}

##Qualification Endpoints


##Essential Rewards Base URL: https://youngliving.com/api/shopping/essential-rewards ###Endpoints

  • GET: /info

###Examples

####Get essential rewards information Example Request:

GET
https://youngliving.com/api/shopping/essential-rewards/info

Example Result:

{
	"totalPoints": 96,
	"totalExpiringPoints30Days": 0,
	"consecutiveMonthsOfErOrders": 12,
	"earningPercentage": 15,
	"availableMonthlyPoints": 96,
	"monthsBeforePercentageIncrease": 0,
	"nextEarningRate": 0,
	"isEnrolled": true,
	"payments": [ ],
	"legacyOtgProcessingDayOfMonth": 1,
	"legacyNfrProcessingDayOfMonth": 1,
	"isErTemplateConfirmed": true,
	"areErDeliveriesValid": true,
	"doesTemplateMeetMinPv": true,
	"otg": {
		"processingDate": {
			"year": 2014,
			"month": 12,
			"day": 1
		}
	},
	"nfr": {
		"processingDate": {
			"year": 2014,
			"month": 11,
			"day": 1
		}
	}
}

##Helpers

function getPeriodId(date) { // Defaults to Current Period if you leave 'date' empty
    date = date instanceof Date ? date : new Date();
    return (date.getFullYear() * 12 + date.getMonth() + 1) - (2014 * 12 + 5) + 400;
}
@jrcano
Copy link

jrcano commented Aug 3, 2020

Here is a sample in .net c#

using (var client = new HttpClient())
{
string baseURL = @"https://www.youngliving.com/";
client.BaseAddress = new Uri(baseURL);
var credentials = new
{
memberId = @"your MemberId",
password = "your Password"
};
var jsonCredentials = JsonConvert.SerializeObject(credentials);
var requestBody = new StringContent(jsonCredentials);
requestBody.Headers.ContentType = new MediaTypeHeaderValue("application/json");
//HTTP POST
var getTask = client.PostAsync("api/accounts/token", requestBody);
getTask.Wait();
//res = getTask.Result.StatusCode.ToString();
if (getTask.Result.IsSuccessStatusCode)
{
var readTask = getTask.Result.Content.ReadAsStringAsync();
readTask.Wait();
var plainToken = System.Text.Encoding.UTF8.GetBytes(readTask.Result);
var token64 = System.Convert.ToBase64String(plainToken);
client.DefaultRequestHeaders.Add("authtoken", token64);
// The last parameter is the period Id, if you don't know it you can use 0 for the current Period
var getUser = client.GetAsync("vo.dlv.api/downline/children/yourMemberId/0");
getUser.Wait();
if (getUser.Result.IsSuccessStatusCode)
{
var readUser = getUser.Result.Content.ReadAsStringAsync();
readUser.Wait();
// The result is a json with your results
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment