PHP code example of felipeva / api-colombia-php

1. Go to this page and download the library: Download felipeva/api-colombia-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

felipeva / api-colombia-php example snippets


use FelipeVa\ApiColombia\ApiColombia;

$client = ApiColombia::client();

// Get all departments
$departments = $client->departments()->all();

foreach ($departments as $department) {
    echo $department->name;
}

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;
}

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;
// ...

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
    // ...
}

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

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
    // ...
}

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
    // ...
}

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

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
    // ...
}

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
    // ...
}

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
    // ...
}

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
    // ...
}

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
    // ...
}

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;
    // ...
}

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
    // ...
}

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;
// ...

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;
    // ...
}

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;
    // ...
}

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;
    // ...
}

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;
    // ...
}

use FelipeVa\ApiColombia\ApiColombia;

$client = ApiColombia::client();
$president = $client->presidents()->get(1);

// Returns a President object
$president->id;
$president->name;
$president->lastName;
$president->description;
// ...

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;
    // ...
}

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;
    // ...
}

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;
    // ...
}

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
    // ...
}

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
// ...

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
    // ...
}

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
    // ...
}

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
    // ...
}

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
    // ...
}

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
// ...

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
    // ...
}

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
    // ...
}

use FelipeVa\ApiColombia\ApiColombia;

$client = ApiColombia::client();
$naturalArea = $client->naturalAreas()->get(1);

// Returns a NaturalArea object
$naturalArea->id;
$naturalArea->name;
$naturalArea->categoryNaturalArea; // CategoryNaturalArea object
// ...

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
    // ...
}

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
    // ...
}

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
    // ...
}

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;
    // ...
}

use FelipeVa\ApiColombia\ApiColombia;

$client = ApiColombia::client();
$map = $client->maps()->get(1);

// Returns a Map object
$map->id;
$map->name;
$map->description;
// ...
bash
composer