PHP Classes

PHP Saudi Arabia Addresses: Get location details from the Saudi National API

Recommend this page to a friend!
  Info   View files Documentation   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 32 All time: 10,957 This week: 96Up
Version License PHP version Categories
saudiaddress 1.0Custom (specified...5PHP 5, Web services, Geography
Description 

Author

This package is specific mainly for applications used in Saudi Arabia Saudi Arabia .

This package can get location details from the Saudi National API.

It can send HTTP requests to the Saudi National API Web server to get several types of information related with addresses in Saudi Arabia.

Currently it can get a list of regions, cities, districts and verify an address or geocode.

Innovation Award
PHP Programming Innovation award nominee
February 2019
Number 10
Saudi Arabia is a well known country of the middle-east that also uses the Arabic language that is very popular in many other countries of the region.

This package can retrieve relevant details of location of Saudi Arabia, as well can verify the address of a country.

Manuel Lemos
Picture of Naif Alshaye
  Performance   Level  
Name: Naif Alshaye <contact>
Classes: 24 packages by
Country: Saudi Arabia Saudi Arabia
Innovation award
Innovation award
Nominee: 9x

Documentation

PHP Laravel wrapper for the Saudi National Address APIs

Installation

composer require naif/saudiaddress

If your Laravel below 5.5 you need to add service provider and alias to config/app.php

Naif\Saudiaddress\SaudiAddressServiceProvider::class,
'SaudiAddress' => Naif\Saudiaddress\Facades\SaudiAddress::class,

API KEYS

Obtain your National Address API key from https://api.address.gov.sa/

Add these to your .env

SAUDI_ADDRESS_API_URL=https://apina.address.gov.sa/NationalAddress/v3.1
SAUDI_ADDRESS_API_KEY=XXXXXXXXXXXXXXXXX

Usage

Get a list of regions

$regions = SaudiAddress::regions();

Response:
[
  0 => {#181
    +"Id": "12"
    +"Name": " ??????"
  }
  1 => {#182
    +"Id": "13"
    +"Name": " ?????"
  }
  2 => {#188
    +"Id": "9"
    +"Name": " ?????? ????????"
  }
  3 => {#189
    +"Id": "1"
    +"Name": " ??????"
  }
]

Get a list of cities within a region (by region id) * To get a list of all cities don't pass a region id

$cities = SaudiAddress::cities(1);

Response:
[
  0 => {#183
    +"Id": "3"
    +"Name": "??????"
  }
  1 => {#189
    +"Id": "1061"
    +"Name": "?????"
  }
  2 => {#190
    +"Id": "828"
    +"Name": "???????"
  }
  3 => {#191
    +"Id": "669"
    +"Name": "????????"
  }
]

Get a list of districts within a city (by city id)

$districts = SaudiAddress::districts(1);

Response:
[
  0 => {#184
    +"Id": "10700001041"
    +"Name": "????? ??? ????? ?????"
  }
  1 => {#190
    +"Id": "10700001018"
    +"Name": "?? ??? ????"
  }
  2 => {#191
    +"Id": "10700001021"
    +"Name": "?? ????????"
  }
  3 => {#192
    +"Id": "10700001030"
    +"Name": "?? ????????"
  }
  4 => {#193
    +"Id": "10700001044"
    +"Name": "?? ???????"
  }
  5 => {#194
    +"Id": "10700001012"
    +"Name": "?? ??????"
  }
]

Geocode, to get address details by geo location (latitude,longitude)

$address = SaudiAddress::geoCode(24.774265,46.738586);

Response:
[
  +"Title": null
  +"Address1": "7596 ??????? - Al Hamra Dist.,?? ???????"
  +"Address2": "RIYADH,?????? 13216 - 2802"
  +"ObjLatLng": "1"
  +"BuildingNumber": "7596"
  +"Street": "???????"
  +"District": "Al Hamra Dist.,?? ???????"
  +"City": "RIYADH,??????"
  +"PostCode": "13216"
  +"AdditionalNumber": "2802"
  +"RegionName": "????? ??????"
  +"PolygonString": null
  +"IsPrimaryAddress": null
  +"UnitNumber": null
  +"Latitude": null
  +"Longitude": null
  +"CityId": "3"
  +"RegionId": null
  +"Restriction": "Null"
  +"PKAddressID": null
  +"DistrictID": null
  +"Title_L2": null
  +"RegionName_L2": null
  +"City_L2": null
  +"Street_L2": null
  +"District_L2": null
  +"CompanyName_L2": null
  +"GovernorateID": null
  +"Governorate": null
  +"Governorate_L2": null
  ]

Verify an address by (Bulding No, PostCode, Additional No)

$verify = SaudiAddress::verify(7596,13216,2802);

Response:

true/false

To get results in English, just pass 'E' as a last paramater. Example

$districts = SaudiAddress::districts(1,'E');

Support:

naif@naif.io

https://www.linkedin.com/in/naif

License

The MIT License (MIT). Please see License File for more information.


  Files folder image Files  
File Role Description
Files folder imagesrc (2 files, 2 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageconfig (1 file)
Files folder imageFacades (1 file)
  Plain text file SaudiAddress.php Class Class source
  Plain text file SaudiAddressServiceProvider.php Class Class source

  Files folder image Files  /  src  /  config  
File Role Description
  Accessible without login Plain text file saudiaddress.php Aux. Auxiliary script

  Files folder image Files  /  src  /  Facades  
File Role Description
  Plain text file SaudiAddress.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:32
This week:0
All time:10,957
This week:96Up