A RESTful API for travel and tour applications that allows storing and retrieving user names and locations. This API helps tour guides see where users are located.
POST /api/location/create.php - Create a new location
{
"name": "John Doe",
"latitude": 37.7749,
"longitude": -122.4194,
"location_name": "San Francisco",
"device_mac": "00:1A:2B:3C:4D:5E", // Optional
"email": "john@example.com", // Optional
"password": "securepassword", // Optional
"is_tourguide": false, // Optional, default is false
"tour_guide_id": 1 // Optional
}
Note: If device_mac is not provided, the API will attempt to detect it.
curl -X POST -H "Content-Type: application/json" -d '{"name":"John Doe","latitude":37.7749,"longitude":-122.4194,"location_name":"San Francisco","email":"john@example.com","password":"securepassword","is_tourguide":false,"tour_guide_id":1}' http://charlzdemosystem.site/api/location/create.php
GET /api/location/read_by_name.php?name=John%20Doe - Get locations for a specific name
curl -X GET http://charlzdemosystem.site/api/location/read_by_name.php?name=John%20Doe
GET /api/location/read_by_device.php?device_mac=00:1A:2B:3C:4D:5E - Get locations for a specific device
curl -X GET http://charlzdemosystem.site/api/location/read_by_device.php?device_mac=00:1A:2B:3C:4D:5E
GET /api/location/read_by_email.php?email=john@example.com - Get locations for a specific email
curl -X GET http://charlzdemosystem.site/api/location/read_by_email.php?email=john@example.com
GET /api/location/read_by_tour_guide.php?tour_guide_id=1 - Get locations for a specific tour guide
curl -X GET http://charlzdemosystem.site/api/location/read_by_tour_guide.php?tour_guide_id=1
GET /api/location/read_by_id.php?id=1 - Get location by ID
curl -X GET http://charlzdemosystem.site/api/location/read_by_id.php?id=1
GET /api/location/read_by_id.php?device_mac=00:1A:2B:3C:4D:5E - Get locations by device MAC using the ID endpoint
Note: You can provide either `id` to get a specific location or `device_mac` to get all locations for a device.
curl -X GET http://charlzdemosystem.site/api/location/read_by_id.php?device_mac=00:1A:2B:3C:4D:5E
GET /api/location/read_all.php - Get all locations (for tour guides)
curl -X GET http://charlzdemosystem.site/api/location/read_all.php
POST /api/location/login.php - Login with email and password
{
"email": "john@example.com",
"password": "securepassword"
}
curl -X POST -H "Content-Type: application/json" -d '{"email":"john@example.com","password":"securepassword"}' http://charlzdemosystem.site/api/location/login.php
PUT /api/location/update.php - Update an existing location
{
"id": 1,
"name": "John Doe",
"latitude": 37.7749,
"longitude": -122.4194,
"location_name": "Golden Gate Park",
"device_mac": "00:1A:2B:3C:4D:5E", // Optional
"email": "john@example.com", // Optional
"password": "securepassword", // Optional
"is_tourguide": true, // Optional
"tour_guide_id": 2 // Optional
}
Note: `id` is required to identify which record to update.
curl -X PUT -H "Content-Type: application/json" -d '{"id":1,"name":"John Doe","latitude":37.7749,"longitude":-122.4194,"location_name":"Golden Gate Park","email":"john.updated@example.com","password":"newsecurepassword","is_tourguide":true,"tour_guide_id":2}' http://charlzdemosystem.site/api/location/update.php
PUT /api/location/update_tour_guide.php - Update only the tour guide for a location
{
"id": 1,
"tour_guide_id": 2
}
Note: This simplified endpoint allows tourists to easily select or change their tour guide.
curl -X PUT -H "Content-Type: application/json" -d '{"id":1,"tour_guide_id":2}' http://charlzdemosystem.site/api/location/update_tour_guide.php
DELETE /api/location/delete.php - Delete a location
{
"id": 1
}
curl -X DELETE -H "Content-Type: application/json" -d '{"id":1}' http://charlzdemosystem.site/api/location/delete.php
DELETE /api/location/delete.php - Delete a location as a tour guide
{
"id": 1,
"tour_guide_id": 2
}
Note: Including tour_guide_id verifies the tour guide has permission to delete this location.
curl -X DELETE -H "Content-Type: application/json" -d '{"id":1,"tour_guide_id":2}' http://charlzdemosystem.site/api/location/delete.php
DELETE /api/location/delete_by_tour_guide.php - Delete all locations for a tour guide
{
"tour_guide_id": 1
}
Note: This will delete all locations assigned to the specified tour guide.
curl -X DELETE -H "Content-Type: application/json" -d '{"tour_guide_id":1}' http://charlzdemosystem.site/api/location/delete_by_tour_guide.php
POST /api/tourguide/create.php or /api/tourguide/register.php - Create a new tour guide
{
"name": "John Smith",
"email": "john@example.com",
"password": "securepassword123",
"is_tourguide": true // Optional, default is true
}
Note: Email must be unique.
curl -X POST -H "Content-Type: application/json" -d '{"name":"John Smith","email":"john@example.com","password":"securepassword123","is_tourguide":true}' http://charlzdemosystem.site/api/tourguide/create.php
POST /api/tourguide/login.php - Login as a tour guide
{
"email": "john@example.com",
"password": "securepassword123"
}
curl -X POST -H "Content-Type: application/json" -d '{"email":"john@example.com","password":"securepassword123"}' http://charlzdemosystem.site/api/tourguide/login.php
GET /api/tourguide/read_all.php - Get all tour guides
Note: This endpoint allows tourists to view and select from available tour guides.
curl -X GET http://charlzdemosystem.site/api/tourguide/read_all.php
{
"id": 1,
"name": "John Doe",
"latitude": "37.77490000",
"longitude": "-122.41940000",
"location_name": "San Francisco",
"device_mac": "00:1A:2B:3C:4D:5E",
"email": "john@example.com",
"is_tourguide": false,
"tour_guide_id": "1",
"timestamp": "2025-03-31 14:30:00"
}
{
"message": "Login successful.",
"id": "1",
"name": "John Smith",
"email": "john@example.com",
"is_tourguide": true
}
{
"records": [
{
"id": "1",
"name": "John Smith",
"email": "john@example.com",
"is_tourguide": true,
"created_at": "2025-03-31 14:30:00"
},
{
"id": "2",
"name": "Jane Doe",
"email": "jane@example.com",
"is_tourguide": true,
"created_at": "2025-03-31 15:45:00"
}
]
}
The API includes comprehensive error handling with appropriate HTTP status codes:
Import the database.sql file into your MySQL server to create the necessary database and tables:
mysql -u root -p < database.sql
Or you can copy and paste the SQL commands from the file into your MySQL client.
POST /api/tourplace/create.php - Create a new tour place
{
"name": "Petite France",
"description": "A French cultural village in South Korea",
"latitude": 37.714892,
"longitude": 127.490324,
"google_maps_url": "https://www.google.com/maps/place/Petite+France",
"image_url": "https://example.com/image.jpg" // Optional
}
curl -X POST -H "Content-Type: application/json" -d '{"name":"Petite France","description":"A French cultural village in South Korea","latitude":37.714892,"longitude":127.490324,"google_maps_url":"https://www.google.com/maps/place/Petite+France"}' http://charlzdemosystem.site/api/tourplace/create.php
GET /api/tourplace/read_all.php - Get all tour places
curl -X GET http://charlzdemosystem.site/api/tourplace/read_all.php
GET /api/tourplace/read_one.php?id=1 - Get a specific tour place by ID
curl -X GET http://charlzdemosystem.site/api/tourplace/read_one.php?id=1
GET /api/tourplace/search.php?name=Seoul - Search tour places by name
curl -X GET http://charlzdemosystem.site/api/tourplace/search.php?name=Seoul
POST /api/tourplace/update.php - Update an existing tour place
{
"id": 1,
"name": "Petite France",
"description": "Updated description for the French cultural village",
"latitude": 37.714892,
"longitude": 127.490324,
"google_maps_url": "https://www.google.com/maps/place/Petite+France",
"image_url": "https://example.com/updated-image.jpg" // Optional
}
curl -X POST -H "Content-Type: application/json" -d '{"id":1,"name":"Petite France","description":"Updated description for the French cultural village","latitude":37.714892,"longitude":127.490324,"google_maps_url":"https://www.google.com/maps/place/Petite+France"}' http://charlzdemosystem.site/api/tourplace/update.php
POST /api/tourplace/delete.php - Delete a tour place
{
"id": 1
}
curl -X POST -H "Content-Type: application/json" -d '{"id":1}' http://charlzdemosystem.site/api/tourplace/delete.php
GET /api/tourplace/api.php - Unified API endpoint for tour places
This single endpoint provides multiple operations through query parameters:
/api/tourplace/api.php/api/tourplace/api.php?id=1/api/tourplace/api.php?search=Seoulcurl -X GET http://charlzdemosystem.site/api/tourplace/api.php
curl -X GET http://charlzdemosystem.site/api/tourplace/api.php?id=1
curl -X GET http://charlzdemosystem.site/api/tourplace/api.php?search=Seoul
{
"id": "1",
"name": "Petite France",
"description": "A French cultural village in South Korea",
"latitude": "37.71489200",
"longitude": "127.49032400",
"google_maps_url": "https://www.google.com/maps/place/Petite+France",
"image_url": "https://example.com/image.jpg",
"created_at": "2025-04-24 10:30:00",
"updated_at": "2025-04-24 10:30:00"
}
{
"records": [
{
"id": "1",
"name": "Petite France",
"description": "A French cultural village in South Korea",
"latitude": "37.71489200",
"longitude": "127.49032400",
"google_maps_url": "https://www.google.com/maps/place/Petite+France",
"image_url": "https://example.com/image.jpg",
"created_at": "2025-04-24 10:30:00",
"updated_at": "2025-04-24 10:30:00"
},
{
"id": "2",
"name": "Nami Island",
"description": "A half-moon shaped island famous for its tree-lined roads",
"latitude": "37.79694700",
"longitude": "127.52569200",
"google_maps_url": "https://www.google.com/maps?ll=37.796947,127.525692&z=13&t=m&hl=en-US&gl=US&mapclient=embed&q=Nami+island",
"image_url": null,
"created_at": "2025-04-24 10:30:00",
"updated_at": "2025-04-24 10:30:00"
}
]
}
We've created an interactive map to visualize all the tour places in the database. You can:
See the README.md file for detailed documentation and usage examples.