use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
// Get all departments
$departments = $client->departments()->all();
foreach ($departments as $department) {
echo $department->name;
}
Api Colombia PHP is a PHP API client that lets you easily interact with the Api Colombia.
Requires PHP 8.2+
First, install the package via the Composer package manager:
composer require felipeva/api-colombia-php
Then, you're ready to start using the package:
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
// Get all cities
$cities = $client->cities()->all();
foreach ($cities as $city) {
echo $city->name;
}
// Get all departments
$departments = $client->departments()->all();
foreach ($departments as $department) {
echo $department->name;
}
Retrieves general information about Colombia.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$country = $client->countries()->get('Colombia');
// Returns a Country object
$country->name; // Colombia
$country->surface;
$country->population;
$country->languages;
// ...
Retrieves all regions in Colombia.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$regions = $client->regions()->all();
// Returns a Listed object of Region objects
foreach ($regions->data as $region) {
$region->id;
$region->name;
$region->description;
$region->departments; // Array of Department objects
// ...
}
Retrieves a region by its id.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$region = $client->regions()->get(1);
// Returns a Region object
$region->id;
$region->name;
$region->description;
$region->departments; // Array of Department objects
Retrieves all departments in a region.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$regionDepartments = $client->regions()->departments(1);
// Returns a Listed object of Department objects
foreach ($regionDepartments->data as $department) {
$department->id;
$department->name;
$department->description;
$department->cities; // Array of City objects
// ...
}
Retrieves all departments in Colombia.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$departments = $client->departments()->all();
// Returns a Listed object of Department objects
foreach ($departments->data as $department) {
$department->id;
$department->name;
$department->description;
$department->cities; // Array of City objects
// ...
}
Retrieves a department by its id.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$department = $client->departments()->get(1);
// Returns a Department object
$department->id;
$department->name;
$department->description;
$department->cities; // Array of City objects
Retrieves all cities in a department.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$departmentCities = $client->departments()->cities(1);
// Returns a Listed object of City objects
foreach ($departmentCities->data as $city) {
$city->id;
$city->name;
$city->description;
$city->population;
$city->surface;
$city->department; // Department object
// ...
}
Retrieves all natural areas in a department.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$departmentNaturalAreas = $client->departments()->naturalAreas(1);
// Returns a Listed object of NaturalArea objects
foreach ($departmentNaturalAreas->data as $naturalArea) {
$naturalArea->id;
$naturalArea->name;
$naturalArea->department; // Department object
// ...
}
Retrieves all tourist attractions in a department.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$departmentTouristAttractions = $client->departments()->touristAttractions(1);
// Returns a Listed object of TouristAttraction objects
foreach ($departmentTouristAttractions->data as $touristAttraction) {
$touristAttraction->id;
$touristAttraction->name;
$touristAttraction->description;
$touristAttraction->city; // City object
// ...
}
Retrieves a department by its name.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$department = $client->departments()->getByName('Antioquia');
// Returns a Listed object of Department objects
foreach ($department->data as $department) {
$department->id;
$department->name;
$department->description;
$department->cities; // Array of City objects
// ...
}
Searches for departments by the following fields: Name, Description, PhonePrefix.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$departments = $client->departments()->search('Antioquia');
// Returns a Listed object of Department objects
foreach ($departments->data as $department) {
$department->id;
$department->name;
$department->description;
$department->cities; // Array of City objects
// ...
}
Retrieves a paged list of departments.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$departments = $client->departments()->paged(page: 1, pageSize: 10);
$departments->page; // 1
$departments->pageSize; // 10
$departments->totalRecords; // number of records
// Returns a Paged object of Department objects
foreach ($departments->data as $department) {
$department->id;
$department->name;
$department->description;
// ...
}
Retrieves all cities in Colombia.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$cities = $client->cities()->all();
// Returns a Listed object of City objects
foreach ($cities->data as $city) {
$city->id;
$city->name;
$city->description;
$city->population;
$city->surface;
$city->department; // Department object
// ...
}
Retrieves a city by its id.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$city = $client->cities()->get(1);
// Returns a City object
$city->id;
$city->name;
$city->description;
$city->population;
$city->surface;
// ...
Retrieves a city by its name.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$city = $client->cities()->getByName('Medellín');
// Returns a Listed object of City objects
foreach ($city->data as $city) {
$city->id;
$city->name;
$city->description;
$city->population;
$city->surface;
// ...
}
Searches for cities by the following fields: Name, Description, PostalCode.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$cities = $client->cities()->search('Medellín');
// Returns a Listed object of City objects
foreach ($cities->data as $city) {
$city->id;
$city->name;
$city->description;
$city->population;
$city->surface;
// ...
}
Retrieves a paged list of cities.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$cities = $client->cities()->paged(page: 1, pageSize: 10);
$cities->page; // 1
$cities->pageSize; // 10
$cities->totalRecords; // number of records
// Returns a Paged object of City objects
foreach ($cities->data as $city) {
$city->id;
$city->name;
$city->description;
$city->population;
$city->surface;
// ...
}
Retrieves all presidents in Colombia.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$presidents = $client->presidents()->all();
// Returns a Listed object of President objects
foreach ($presidents->data as $president) {
$president->id;
$president->name;
$president->lastName;
$president->description;
// ...
}
Retrieves a president by its id.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$president = $client->presidents()->get(1);
// Returns a President object
$president->id;
$president->name;
$president->lastName;
$president->description;
// ...
Retrieves a president by its name.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$president = $client->presidents()->getByName('Gustavo Petro');
// Returns a Listed object of President objects
foreach ($president->data as $president) {
$president->id;
$president->name;
$president->lastName;
$president->description;
// ...
}
Retrieves a president by its year.
To be implemented..
Searches for presidents by the following fields: Name, Description, PoliticalParty,LastName
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$presidents = $client->presidents()->search('Gustavo Petro');
// Returns a Listed object of President objects
foreach ($presidents->data as $president) {
$president->id;
$president->name;
$president->lastName;
$president->description;
// ...
}
Retrieves a paged list of presidents.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$presidents = $client->presidents()->paged(page: 1, pageSize: 10);
$presidents->page; // 1
$presidents->pageSize; // 10
$presidents->totalRecords; // number of records
// Returns a Paged object of President objects
foreach ($presidents->data as $president) {
$president->id;
$president->name;
$president->lastName;
$president->description;
// ...
}
Retrieves all touristic attractions in Colombia.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$touristicAttractions = $client->touristAttractions()->all();
// Returns a Listed object of TouristicAttraction objects
foreach ($touristicAttractions->data as $touristicAttraction) {
$touristicAttraction->id;
$touristicAttraction->name;
$touristicAttraction->description;
$touristicAttraction->city; // City object
// ...
}
Retrieves a touristic attraction by its id.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$touristicAttraction = $client->touristAttractions()->get(1);
// Returns a TouristicAttraction object
$touristicAttraction->id;
$touristicAttraction->name;
$touristicAttraction->description;
$touristicAttraction->city; // City object
// ...
Retrieves a touristic attraction by its name.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$touristicAttraction = $client->touristAttractions()->getByName('Catedral de Sal de Zipaquirá');
// Returns a Listed object of TouristicAttraction objects
foreach ($touristicAttraction->data as $touristicAttraction) {
$touristicAttraction->id;
$touristicAttraction->name;
$touristicAttraction->description;
$touristicAttraction->city; // City object
// ...
}
Searches for touristic attractions by the following fields: Name, Description,LastName,Latitude, Longitude
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$touristicAttractions = $client->touristAttractions()->search('Catedral de Sal de Zipaquirá');
// Returns a Listed object of TouristicAttraction objects
foreach ($touristicAttractions->data as $touristicAttraction) {
$touristicAttraction->id;
$touristicAttraction->name;
$touristicAttraction->description;
$touristicAttraction->city; // City object
// ...
}
Retrieves a paged list of touristic attractions.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$touristicAttractions = $client->touristAttractions()->paged(page: 1, pageSize: 10);
$touristicAttractions->page; // 1
$touristicAttractions->pageSize; // 10
$touristicAttractions->totalRecords; // number of records
// Returns a Paged object of TouristicAttraction objects
foreach ($touristicAttractions->data as $touristicAttraction) {
$touristicAttraction->id;
$touristicAttraction->name;
$touristicAttraction->description;
$touristicAttraction->city; // City object
// ...
}
Retrieves all categories of natural areas in Colombia.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$categoriesNaturalArea = $client->categoryNaturalAreas()->all();
// Returns a Listed object of CategoryNaturalArea objects
foreach ($categoriesNaturalArea->data as $categoryNaturalArea) {
$categoryNaturalArea->id;
$categoryNaturalArea->name;
$categoryNaturalArea->description;
$categoryNaturalArea->naturalAreas; // array of NaturalArea objects
// ...
}
Retrieves a category of natural areas by its id.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$categoryNaturalArea = $client->categoryNaturalAreas()->get(1);
// Returns a CategoryNaturalArea object
$categoryNaturalArea->id;
$categoryNaturalArea->name;
$categoryNaturalArea->description;
$categoryNaturalArea->naturalAreas; // array of NaturalArea objects
// ...
Retrieves all natural areas of a category by its id.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$naturalAreas = $client->categoryNaturalAreas()->naturalAreas(1);
// Returns a Listed object of NaturalArea objects
foreach ($naturalAreas->data as $naturalArea) {
$naturalArea->id;
$naturalArea->name;
$naturalArea->categoryNaturalArea; // CategoryNaturalArea object
// ...
}
Retrieves all natural areas in Colombia.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$naturalAreas = $client->naturalAreas()->all();
// Returns a Listed object of NaturalArea objects
foreach ($naturalAreas->data as $naturalArea) {
$naturalArea->id;
$naturalArea->name;
$naturalArea->categoryNaturalArea; // CategoryNaturalArea object
// ...
}
Retrieves a natural area by its id.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$naturalArea = $client->naturalAreas()->get(1);
// Returns a NaturalArea object
$naturalArea->id;
$naturalArea->name;
$naturalArea->categoryNaturalArea; // CategoryNaturalArea object
// ...
Retrieves a natural area by its name.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$naturalArea = $client->naturalAreas()->getByName('Parque Nacional Natural Tayrona');
// Returns a Listed object of NaturalArea objects
foreach ($naturalArea->data as $naturalArea) {
$naturalArea->id;
$naturalArea->name;
$naturalArea->categoryNaturalArea; // CategoryNaturalArea object
// ...
}
Searches for natural areas by the following fields: Name, Description,LastName,Latitude, Longitude
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$naturalAreas = $client->naturalAreas()->search('Parque Nacional Natural Tayrona');
// Returns a Listed object of NaturalArea objects
foreach ($naturalAreas->data as $naturalArea) {
$naturalArea->id;
$naturalArea->name;
$naturalArea->categoryNaturalArea; // CategoryNaturalArea object
// ...
}
Retrieves a paged list of natural areas.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$naturalAreas = $client->naturalAreas()->paged(page: 1, pageSize: 10);
$naturalAreas->page; // 1
$naturalAreas->pageSize; // 10
$naturalAreas->totalRecords; // number of records
// Returns a Paged object of NaturalArea objects
foreach ($naturalAreas->data as $naturalArea) {
$naturalArea->id;
$naturalArea->name;
$naturalArea->categoryNaturalArea; // CategoryNaturalArea object
// ...
}
Retrieves all maps in Colombia.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$maps = $client->maps()->all();
// Returns a Listed object of Map objects
foreach ($maps->data as $map) {
$map->id;
$map->name;
$map->description;
// ...
}
Retrieves a map by its id.
use FelipeVa\ApiColombia\ApiColombia;
$client = ApiColombia::client();
$map = $client->maps()->get(1);
// Returns a Map object
$map->id;
$map->name;
$map->description;
// ...