Search code examples
apiyelp

Day numbering in Yelp API


When Yelp API returns data for each day of the week, like the hours when business is open, the first day is 0 and the last one is 6. Is it safe to assume that 0 corresponds to Sunday?

"hours": [
{
  "hours_type": "REGULAR",
  "open": [
    {
      "is_overnight": false,
      "end": "2200",
      "day": 0,
      "start": "1730"
    },
    {
      "is_overnight": false,
      "end": "2200",
      "day": 1,
      "start": "1730"
    },
    {
      "is_overnight": false,
      "end": "2200",
      "day": 2,
      "start": "1730"
    },
    {
      "is_overnight": false,
      "end": "2200",
      "day": 3,
      "start": "1730"
    },
    {
      "is_overnight": false,
      "end": "2200",
      "day": 4,
      "start": "1730"
    },
    {
      "is_overnight": false,
      "end": "2200",
      "day": 5,
      "start": "1730"
    },
    {
      "is_overnight": false,
      "end": "2200",
      "day": 6,
      "start": "1730"
    }
  ],
  "is_open_now": false
}

],


Solution

  • Hope you are using latest api version (v3). you can refer to the yelp api documentation https://www.yelp.com/developers/documentation/v3/business which clearly says days 0-6 should be considered as monday to sunday

    From the documentaion

    hours[x].open[x].day int From 0 to 6, representing day of the week from Monday to Sunday. Notice that you may get the same day of the week more than once if the business has more than one opening time slots.