salamwaddah/passport-visa-api

Passport Visa API - an unofficial passportindex.org API

1.1.0 2024-01-28 15:26 UTC

This package is auto-updated.

Last update: 2024-04-29 07:17:15 UTC


README

Latest Version on Packagist Total Downloads MIT Licensed

An unofficial passportindex.org API - supports 199 passports

Showcase website

Installation

You can install the package via composer:

composer require salamwaddah/passport-visa-api

Usage

You can get all the visa requirements for a passport by using the get() method.

require_once __DIR__ . '/../vendor/autoload.php';

$passport = \SalamWaddah\PassportVisa\Passport::make('ma');

$passport->get();
// [
//     "visa-free" => ["tr", etc...],
//     "visa-on-arrival" => ["lb", etc...],
//     "electronic-travel-authorization" => ["kr", etc...],
//     "e-visa" => ["jo", etc...],
//     "visa-required" => ["gb", etc...],
//     "not-admitted" => [],
//     "covid-ban" => [],
// ]

Alternatively you can get the visa requirements for a passport by using the methods:

  • listVisaFree()
  • listVisaOnArrival()
  • listEta()
  • listEVisa()
  • listVisaRequired()
  • listNotAdmitted()
  • listCovidBan()
// list of visa free countries for your $passport
$passport->listVisaFree(); // returns ["tr", etc...]

// list of countries which do not admit your $passport
$passport->listNotAdmitted(); // returns []

Caching

This library does not cache the results, you can use your own caching mechanism to avoid unnecessarily calling passportindex.org everytime. A recommended TTL for your cache is 1 day.

Testing

composer test