API Documentation

REST API documentation with endpoints, parameters, and example responses.

API Overview

The Me Live Code REST API provides fake data endpoints for testing and prototyping.

Rate Limiting & Data Reset

The database resets every 10 minutes to provide fresh demo data.

Available Endpoints

USERS API

(9 endpoints)
GET USER LIST: api/users
Response:
Code: 200
[
  {
      "id": 1,
      "fname": "Karn",
      "lname": "Yong",
      "username": "karn.yong",
      "avatar": "https://www.melivecode.com/users/1.png"
  },
  {
      "id": 2,
      "fname": "Ivy",
      "lname": "Cal",
      "username": "ivy.cal",
      "avatar": "https://www.melivecode.com/users/2.png"
  },
  {
      "id": 3,
      "fname": "Walter",
      "lname": "Beau",
      "username": "walter.beau",
      "avatar": "https://www.melivecode.com/users/3.png"
  },
  {
      "id": 4,
      "fname": "Gayla",
      "lname": "Bertrand",
      "username": "gayla.bertrand",
      "avatar": "https://www.melivecode.com/users/4.png"
  },
  ...
]
                              
GET USER LIST (SEARCH): api/users?search={search}
Parameters:
{search}: words for searching
Response:
Code: 200
[
  {
    "id": 1,
    "fname": "Karn",
    "lname": "Yong",
    "username": "karn.yong",
    "avatar": "https://www.melivecode.com/users/1.png"
  }
]
                              
GET USER LIST (PAGINATION): api/users?page={page}&per_page={per_page}
Parameters:
{page}: current page number
{per_page}: number of records per page
Response:
Code: 200
[
  "page": 1,
  "per_page": 10,
  "total": 12,
  "total_pages": 2,
  "data": [
    {
      "id": 1,
      "fname": "Karn",
      "lname": "Yong",
      "username": "karn.yong",
      "avatar": "https://www.melivecode.com/users/1.png"
    },
    {
      "id": 2,
      "fname": "Ivy",
      "lname": "Cal",
      "username": "ivy.cal",
      "avatar": "https://www.melivecode.com/users/2.png"
    },
    {
      "id": 3,
      "fname": "Walter",
      "lname": "Beau",
      "username": "walter.beau",
      "avatar": "https://www.melivecode.com/users/3.png"
    },
    ...
]
                              
GET USER LIST (SORT): api/users?sort_column={sort_column}&sort_order={sort_order}
Parameters:
{sort_column}: a column to be sorted
{sort_order}: sort by asc or desc
Response:
Code: 200
[
  {
    "id": 12,
    "fname": "Katarina",
    "lname": "Aba",
    "username": "katarina.aba",
    "avatar": "https://www.melivecode.com/users/12.png"
  },
  {
    "id": 11,
    "fname": "Adrian",
    "lname": "Faisal",
    "username": "adrian.faisal",
    "avatar": "https://www.melivecode.com/users/11.png"
  },
  ...
]
                              
GET USER LIST (SEARCH + PAGINATION + SORT): api/users?search={search}&page={page}&per_page={per_page}&sort_column={sort_column}&sort_order={sort_order}
Parameters:
{search}: words for searching {page}: current page number
{per_page}: number of records per page
{sort_column}: a column to be sorted
{sort_order}: sort by asc or desc
Response:
Code: 200
[
  "page": 1,
  "per_page": 10,
  "total": 2,
  "total_pages": 1,
  "data": [
    {
      "id": 12,
      "fname": "Katarina",
      "lname": "Aba",
      "username": "katarina.aba",
      "avatar": "https://www.melivecode.com/users/12.png"
    },
    {
      "id": 1,
      "fname": "Karn",
      "lname": "Yong",
      "username": "karn.yong",
      "avatar": "https://www.melivecode.com/users/1.png"
    }
  ]
}
                              
GET USER DETAIL: api/users/{id}
Parameters:
{id}: user id
Response:
Code: 200: Success
{
  "status": "ok",
  "user": {
      "id": 1,
      "fname": "Karn",
      "lname": "Yong",
      "username": "karn.yong",
      "email": "karn.yong@melivecode.com",
      "avatar": "https://www.melivecode.com/users/1.png"
  }
}
                              
Code: 404: Not Found
{
  "status": "error",
  "message": "User with ID = {id} not found"
}
                              
POST USER CREATE: api/users
*Data will be reset to only have the first 12 entries every 15 minutes.
Body:
{
  "fname": "Cat",
  "lname": "Chat",
  "username": "cat.chat",
  "password": "1234",
  "email": "cat.chat@melivecode.com",
  "avatar": "https://www.melivecode.com/users/cat.png"
}
                        
Response:
Code: 200: OK
{
  "status": "ok",
  "message": "User with ID = 11 is created",
  "user": {
    "id": 11,
    "fname": "Cat",
    "lname": "Chat",
    "username": "cat.chat",
    "email": "cat.chat@melivecode.com",
    "avatar": "https://www.melivecode.com/users/cat.png"
  }
}
                              
Code: 400: Bad Request
{
  "status": "error",
  "message": "Missing fields (fname, lname, username, email, and/or avatar)"
}
                              
PUT USER UPDATE: api/users/{id}
*Only id field is mandatory for update. You cannot update the first 12 entries of the user data.
Body:
{
  "lname": "Gato"
}
                        
Response:
Code: 200: OK
{
  "status": "ok",
  "message": "User with ID = 11 is updated",
  "user": {
    "id": 11,
    "fname": "Cat",
    "lname": "Gato",
    "username": "cat.chat",
    "email": "cat.chat@melivecode.com",
    "avatar": "https://www.melivecode.com/users/cat.png"
  }
}
                              
Code: 404: Not Found
{
  "status": "error",
  "message": "User with ID = {id} not found"
}
                              
DELETE USER DELETE: api/users/{id}
*Only id field is mandatory for update. You cannot delete the first 12 entries of the user data.
Response:
Code: 200: OK
{
  "status": "ok",
  "message": "User with ID = 11 is deleted"
}
                              
Code: 404: Not Found
{
  "status": "error",
  "message": "User with ID = {id} not found"
}
                              

USER AUTHORIZATION API

(3 endpoints)
POST LOGIN (JWT): api/login
Header:
Authorization: Bearer {accessToken}
Returns a JWT accessToken. Use it when calling any /api/auth/* endpoints.
Body:
{
  "username": "karn.yong",
  "password": "melivecode",
  "expiresIn": 60000
}
*expiresIn, i.e., token expire time (millisec), is optional

                        
Response:
Code: 200: OK
{
  "status": "ok",
  "message": "Logged in",
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cC...",
  "expiresIn": 60000,
  "user": {
    "id": 1,
    "fname": "Karn",
    "lname": "Yong",
    "username": "karn.yong",
    "email": "karn.yong@melivecode.com",
    "avatar": "https://www.melivecode.com/users/1.png"
  }
}
                              
Code: 400: Bad Request
{
  "status": "error",
  "message": "Missing username and/or password"
}
                              
Code: 401: Unauthorized
{
  "status": "error",
  "message": "Login failed"
}
                              
GET USER DETAIL (JWT): api/auth/users
Header:
Authorization: Bearer {accessToken}
Requires Authorization header.
Response:
Code: 200: Success
{
  "status": "ok",
  "user": {
    "id": 1,
    "fname": "Karn",
    "lname": "Yong",
    "username": "karn.yong",
    "email": "karn.yong@melivecode.com",
    "avatar": "https://www.melivecode.com/users/1.png"
  }
}
                              
Code: 403: Forbidden
{
  "status": "forbidden",
  "message": "Access Token Invalid"
}
                              
Code: 401: Unauthorized
{
  "status": "forbidden",
  "message": "No Authorization Header"
}
                              
GET USER DETAIL (JWT): api/auth/users/{id}
Header:
Authorization: Bearer {accessToken}
Requires Authorization header.
Parameters:
{id}: user id
Response:
Code: 200: Success
{
  "status": "ok",
  "user": {
    "id": 1,
    "fname": "Karn",
    "lname": "Yong",
    "username": "karn.yong",
    "email": "karn.yong@melivecode.com",
    "avatar": "https://www.melivecode.com/users/1.png"
  }
}
                              
Code: 403: Forbidden
{
  "status": "forbidden",
  "message": "Access Token Invalid"
}
                              
Code: 401: Unauthorized
{
  "status": "forbidden",
  "message": "No Authorization Header"
}
                              

ATTRACTIONS API

(11 endpoints)
GET ATTRACTION LIST: api/attractions
Response:
Code: 200
[
  {
    "id": 1,
    "name": "Phi Phi Islands",
    "detail": "Phi Phi Islands are a group of islands in Thailand between the large island of Phuket and the Malacca Coastal Strait of Thailand.",
    "coverimage": "https://www.melivecode.com/attractions/1.jpg",
    "latitude": 7.737619,
    "longitude": 98.7068755
  },
  {
    "id": 2,
    "name": "Eiffel Tower",
    "detail": "Eiffel Tower is one of the most famous structures in the world. Eiffel Tower is named after a leading French architect and engineer. It was built as a symbol of the World Fair in 1889.",
    "coverimage": "https://www.melivecode.com/attractions/2.jpg",
    "latitude": 48.8583736,
    "longitude": 2.2922926
  },
  {
    "id": 3,
    "name": "Times Square",
    "detail": "Times Square has become a global landmark and has become a symbol of New York City. This is a result of Times Square being a modern, futuristic venue, with huge advertising screens dotting its surroundings.",
    "coverimage": "https://www.melivecode.com/attractions/3.jpg",
    "latitude": 40.7589652,
    "longitude": -73.9893574
  },
  {
    "id": 4,
    "name": "Mount Fuji",
    "detail": "Mount Fuji is the highest mountain in Japan, about 3,776 meters (12,388 feet) situated to the west of Tokyo. Mount Fuji can be seen from Tokyo on clear days.",
    "coverimage": "https://www.melivecode.com/attractions/4.jpg",
    "latitude": 35.3606422,
    "longitude": 138.7186086
  },
  ...
]
                              
GET ATTRACTION LIST (SEARCH): api/attractions?search={search}
Parameters:
{search}: words for searching
Response:
Code: 200
[
  {
    "id": 1,
    "name": "Phi Phi Islands",
    "detail": "Phi Phi Islands are a group of islands in Thailand between the large island of Phuket and the Malacca Coastal Strait of Thailand.",
    "coverimage": "https://www.melivecode.com/attractions/1.jpg",
    "latitude": 7.737619,
    "longitude": 98.7068755
  },
  {
    "id": 8,
    "name": "Statue of Liberty",
    "detail": "The Statue of Liberty is a colossal neoclassical sculpture on Liberty Island in New York Harbor in New York City, in the United States. The copper statue, a gift from the people of France to the people of the United States.",
    "coverimage": "https://www.melivecode.com/attractions/8.jpg",
    "latitude": 40.689167,
    "longitude": -74.044444
  }
]
                              
GET ATTRACTION LIST (PAGINATION): api/attractions?page={page}&per_page={per_page}
Parameters:
{page}: current page number
{per_page}: number of records per page
Response:
Code: 200
[
  "page": 1,
  "per_page": 10,
  "total": 12,
  "total_pages": 2,
  "data": [
    {
      "id": 1,
      "name": "Phi Phi Islands",
      "detail": "Phi Phi Islands are a group of islands in Thailand between the large island of Phuket and the Malacca Coastal Strait of Thailand.",
      "coverimage": "https://www.melivecode.com/attractions/1.jpg",
      "latitude": 7.737619,
      "longitude": 98.7068755
    },
    {
      "id": 2,
      "name": "Eiffel Tower",
      "detail": "Eiffel Tower is one of the most famous structures in the world. Eiffel Tower is named after a leading French architect and engineer. It was built as a symbol of the World Fair in 1889.",
      "coverimage": "https://www.melivecode.com/attractions/2.jpg",
      "latitude": 48.8583736,
      "longitude": 2.2922926
    },
    {
      "id": 3,
      "name": "Times Square",
      "detail": "Times Square has become a global landmark and has become a symbol of New York City. This is a result of Times Square being a modern, futuristic venue, with huge advertising screens dotting its surroundings.",
      "coverimage": "https://www.melivecode.com/attractions/3.jpg",
      "latitude": 40.7589652,
      "longitude": -73.9893574
    },
    ...
]
                              
GET ATTRACTION LIST (SORT): api/attractions?sort_column={sort_column}&sort_order={sort_order}
Parameters:
{sort_column}: a column to be sorted
{sort_order}: sort by asc or desc
Response:
Code: 200
[
  {
    "id": 12,
    "name": "Wat Phra Kaew",
    "detail": "Wat Phra Kaew, commonly known in English as the Temple of the Emerald Buddha and officially as Wat Phra Si Rattana Satsadaram, is regarded as the most sacred Buddhist temple in Thailand. The complex consists of a number of buildings within the precincts of the Grand Palace in the historical centre of Bangkok.",
    "coverimage": "https://www.melivecode.com/attractions/12.jpg",
    "latitude": 13.751389,
    "longitude": 100.4925
  },
  {
    "id": 11,
    "name": "Hollywood Sign",
    "detail": "The Hollywood Sign is an American landmark and cultural icon overlooking Hollywood, Los Angeles, California. It is situated on Mount Lee, in the Beachwood Canyon area of the Santa Monica Mountains. Spelling out the word Hollywood in 45 ft (13.7 m)-tall white capital letters and 350 feet (106.7 m) long.",
    "coverimage": "https://www.melivecode.com/attractions/11.jpg",
    "latitude": 34.134061,
    "longitude": -118.321592
  },
  ...
]
                              
GET ATTRACTION LIST (SEARCH + PAGINATION + SORT): api/attractions?search={search}&page={page}&per_page={per_page}&sort_column={sort_column}&sort_order={sort_order}
Parameters:
{search}: words for searching {page}: current page number
{per_page}: number of records per page
{sort_column}: a column to be sorted
{sort_order}: sort by asc or desc
Response:
Code: 200
[
  "page": 1,
  "per_page": 10,
  "total": 2,
  "total_pages": 1,
  "data": [
    {
      "id": 8,
      "name": "Statue of Liberty",
      "detail": "The Statue of Liberty is a colossal neoclassical sculpture on Liberty Island in New York Harbor in New York City, in the United States. The copper statue, a gift from the people of France to the people of the United States.",
      "coverimage": "https://www.melivecode.com/attractions/8.jpg",
      "latitude": 40.689167,
      "longitude": -74.044444
    },
    {
      "id": 1,
      "name": "Phi Phi Islands",
      "detail": "Phi Phi Islands are a group of islands in Thailand between the large island of Phuket and the Malacca Coastal Strait of Thailand.",
      "coverimage": "https://www.melivecode.com/attractions/1.jpg",
      "latitude": 7.737619,
      "longitude": 98.7068755
    }
  ]
}
                              
GET ATTRACTION LIST (LANGUAGE): api/{language}/attractions
Parameters:
{language}: en (English) or th (Thai)
Response:
Code: 200: Success
{
  "id": 1,
  "name": "หมู่เกาะพีพี",
  "detail": "เกาะพีพีเป็นกลุ่มเกาะในประเทศไทยระหว่างเกาะภูเก็ตขนาดใหญ่และช่องแคบชายฝั่งมะละกาของประเทศไทย",
  "coverimage": "https://www.melivecode.com/attractions/1.jpg",
  "latitude": 7.737619,
  "longitude": 98.7068755
},
{
  "id": 2,
  "name": "หอไอเฟล",
  "detail": "หอไอเฟลเป็นหนึ่งในโครงสร้างที่มีชื่อเสียงที่สุดในโลก หอไอเฟล ตั้งชื่อตามสถาปนิกและวิศวกรชาวฝรั่งเศสชั้นนำ สร้างขึ้นเพื่อเป็นสัญลักษณ์ของงาน World Fair ในปี 1889",
  "coverimage": "https://www.melivecode.com/attractions/2.jpg",
  "latitude": 48.8583736,
  "longitude": 2.2922926
},
{
  "id": 3,
  "name": "ไทม์สแควร์",
  "detail": "ไทม์สแควร์ได้กลายเป็นแลนด์มาร์คระดับโลกและได้กลายเป็นสัญลักษณ์ของนิวยอร์กซิตี้แล้ว นี่เป็นผลมาจากการที่ไทม์สแควร์เป็นสถานที่ที่ทันสมัยและล้ำยุคด้วยหน้าจอโฆษณาขนาดใหญ่ที่กระจายอยู่รอบๆ",
  "coverimage": "https://www.melivecode.com/attractions/3.jpg",
  "latitude": 40.7589652,
  "longitude": -73.9893574
},
{
  "id": 4,
  "name": "ภูเขาฟูจิ",
  "detail": "ภูเขาฟูจิเป็นภูเขาที่สูงที่สุดในญี่ปุ่น โดยอยู่ทางตะวันตกของกรุงโตเกียวประมาณ 3,776 เมตร (12,388 ฟุต) มองเห็นภูเขาไฟฟูจิได้จากโตเกียวในวันที่อากาศแจ่มใส",
  "coverimage": "https://www.melivecode.com/attractions/4.jpg",
  "latitude": 35.3606422,
  "longitude": 138.7186086
},
                              
GET ATTRACTION DETAIL: api/attractions/{id}
Parameters:
{id}: attraction id
Response:
Code: 200: Success
{
  "status": "ok",
  "attraction": {
    "id": 1,
    "name": "Phi Phi Islands",
    "detail": "Phi Phi Islands are a group of islands in Thailand between the large island of Phuket and the Malacca Coastal Strait of Thailand.",
    "coverimage": "https://www.melivecode.com/attractions/1.jpg",
    "latitude": 7.737619,
    "longitude": 98.7068755
  }
}
                              
Code: 404: Not Found
{
  "status": "error",
  "message": "Attraction with ID = {id} not found"
}
                              
GET ATTRACTION DETAIL: api/{language}/attractions/{id}
Parameters:
{id}: attraction id
Response:
Code: 200: Success
{
  "status": "ok",
  "attraction": {
    "id": 1,
    "name": "หมู่เกาะพีพี",
    "detail": "เกาะพีพีเป็นกลุ่มเกาะในประเทศไทยระหว่างเกาะภูเก็ตขนาดใหญ่และช่องแคบชายฝั่งมะละกาของประเทศไทย",
    "coverimage": "https://www.melivecode.com/attractions/1.jpg",
    "latitude": 7.737619,
    "longitude": 98.7068755
  }
}
                              
Code: 404: Not Found
{
  "status": "error",
  "message": "Attraction with ID = {id} not found"
}
                              
POST ATTRACTION CREATE (JWT): api/auth/attractions
Header:
Authorization: Bearer {accessToken}
*Data will be reset to only have the first 12 entries every 15 minutes.
Body:
{
    "name": "Rangsit University",
    "detail": "Rangsit University (RSU) is a private university in Pathum Thani, Thailand, focusing mainly on music, design, Information technology, and public health including independent professions",
    "coverimage": "https://www.melivecode.com/attractions/rsu.png",
    "latitude": 13.9642507,
    "longitude": 100.5866942
}
                        
Response:
Code: 200: OK
{
  "status": "ok",
  "message": "Attraction with ID = 13 is created",
  "attraction": {
      "id": 13,
      "name": "Rangsit University",
      "detail": "Rangsit University (RSU) is a private university in Pathum Thani, Thailand, focusing mainly on music, design, Information technology, and public health including independent professions",
      "coverimage": "https://www.melivecode.com/attractions/08.png",
      "latitude": 13.9642507,
      "longitude": 100.5866942
  }
}
                              
Code: 400: Bad Request
{
  "status": "error",
  "message": "Missing fields (name, detail, coverimage, latitude, and/or longitude)"
}
                              
PUT ATTRACTION UPDATE (JWT): api/auth/attractions
Header:
Authorization: Bearer {accessToken}
*Only id field is mandatory for update. You cannot update the first 12 entries of the attraction data.
Body:
{
    "id": 13,
    "name": "Rangsit University (RSU)"
}
                        
Response:
Code: 200: OK
{
  "status": "ok",
  "message": "Attraction with ID = 13 is updated",
  "attraction": {
    "id": 13,
    "name": "Rangsit University (RSU)",
    "detail": "Rangsit University (RSU) is a private university in Pathum Thani, Thailand, focusing mainly on music, design, Information technology, and public health including independent professions",
    "coverimage": "https://www.melivecode.com/attractions/rsu.png",
    "latitude": 13.9642507,
    "longitude": 100.5866942
  }
}
                              
Code: 404: Not Found
{
  "status": "error",
  "message": "Attraction with ID = {id} not found"
}
                              
DELETE ATTRACTION DELETE (JWT): api/attractions
Header:
Authorization: Bearer {accessToken}
*Only id field is mandatory for update. You cannot delete the first 12 entries of the attraction data.
Body:
{
  "id": 13
}
                        
Response:
Code: 200: OK
{
  "status": "ok",
  "message": "Attraction with ID = 13 is deleted"
}
                              
Code: 404: Not Found
{
  "status": "error",
  "message": "Attraction with ID = {id} not found"
}
                              

PET SALES (CHART) API

(2 endpoints)
GET PET SALES SUMMARY (7 DAYS): api/pets/7days/{date}
Response:
Code: 200
{
"series": [
  {
    "name": "dog",
    "data": [
      5643.82,
      1908.44,
      2208.16,
      1749.57,
      1603.84,
      576.27,
      0
    ]
  },
  {
    "name": "cat",
    "data": [
      380.64,
      376.73,
      159.46,
      0,
      468.38,
      123.53,
      0
    ]
  }
],
"categories": [
    "2023-01-23",
    "2023-01-24",
    "2023-01-25",
    "2023-01-26",
    "2023-01-27",
    "2023-01-28",
    "2023-01-29"
  ]
}
                              
GET PET SALES (DAILY): /api/pets/{date}
Response:
Code: 200
[
  {
    "code": "m32158",
    "animalId": 3,
    "date": "2025-02-01",
    "animal": "rabbit",
    "type": "mammal",
    "price": "5312.86"
  },
  {
    "code": "m12158",
    "animalId": 1,
    "date": "2025-02-01",
    "animal": "dog",
    "type": "mammal",
    "price": "5087.72"
  },
  {
    "code": "b92158",
    "animalId": 9,
    "date": "2025-02-01",
    "animal": "parrot",
    "type": "bird",
    "price": "3798.28"
  },
  ...
]
                              

PRODUCT REVIEWS (DAILY) API

(1 endpoints)
GET DAILY REVIEWS: /api/reviews/{date}
Random 10 product reviews for the given date
Response:
Code: 200
{
  "date": "2025-02-01",
  "reviews": [
    {
      "id": 35,
      "productId": 135,
      "productName": "DishClean Pro",
      "review": "ล้างจานสะอาด ใช้ง่ายมาก"
    },
    {
      "id": 23,
      "productId": 123,
      "productName": "CleanBot Mini",
      "review": "ชนขอบประตูบ่อย ไม่ฉลาด"
    },
    {
      "id": 49,
      "productId": 149,
      "productName": "WaveSole Sandals",
      "review": "ใส่เดินไกลได้สบาย ไม่กัดเท้า"
    },
    {
      "id": 28,
      "productId": 128,
      "productName": "DryMate Dryer",
      "review": "ผ้ายับและแห้งไม่ทั่วถึง"
    },
    {
      "id": 17,
      "productId": 117,
      "productName": "USB Hub Ultra",
      "review": "พอร์ตครบ รองรับทุกอุปกรณ์"
    },
    {
      "id": 32,
      "productId": 132,
      "productName": "LightBright LED",
      "review": "สว่างทั่วห้อง ไม่แสบตา"
    },
    {
      "id": 43,
      "productId": 143,
      "productName": "ChicSlim Jeans",
      "review": "ยืดง่ายหลังซัก ทรงเปลี่ยน"
    },
    {
      "id": 31,
      "productId": 131,
      "productName": "EcoHeater Wall",
      "review": "ให้ความร้อนเร็ว ไม่กินไฟ"
    },
    {
      "id": 7,
      "productId": 107,
      "productName": "NoiseBlock Headset",
      "review": "เสียงไม่คม เบสดังเกินไป"
    },
    {
      "id": 8,
      "productId": 108,
      "productName": "4K Vision TV",
      "review": "รีโมทตอบสนองช้า ภาพกระตุก"
    }
  ]
}