Skip to main content

Egyptian national ID validator and data-extractor AP

Project description

Egyptian national ID validator and data-extractor API

https://pypi.python.org/pypi/national-id Actions Status codecov.io

Requirments

  • python3.6 or later
  • pip3
  • bottle

How to run

  • Install requirments pip3 install -r requirements.txt
  • Run python3 server.py
  • Server will be running on port 8001
  • Endpoint can be reached at http://localhost:8001/get_info

Endpoint

  • /get_info
    • Accepts post requests with "Content-Type: application/json" Header

      • Example request:

        curl -H "Content-Type: application/json" -d '{"id_number": "29009121201812"}' -XPOST http://localhost:8001/get_info
        
    • Response

      • 200 OK, json_info: national id is validated and info extraction ok
      • 400 Bad Request: Wrong national id number
      • 500 Internal Server Error: Invalid request from user (invalid json, invalid form of data)

      Example response:

      {"nationl_id_data": {"year_of_birth": "1994", "month_of_birth": "9", "day_of_birth": "15", "governorate": "Al Daqhlia", "type": "Male"}}
      

Validations and checks

The national ID consists of the following:

+-+--+--+--+--+----+-+
|2|90|01|01|12|3456|7|
+--------------------+
|A|B |C |D |E | F  |G|
+-+--+--+--+--+----+-+
  • A -> The century: A=2 From (1900-1999), A=3 From (2000-2099)
  • B~D (Date of birth): B -> Year of birth C -> Month of birth D -> Day of birth
  • E -> Governorate code ex: {12: "Al Daqhlia"}
  • F -> Unique code. (Odd is male, Even is female)
  • G -> Check digit for verification

How to run tests

  • Lib test: pytest -s tests/test_national_id.py
  • Test the endpoint python3 -m pytest -s tests/test_endpoint.py

Dockerfile

  • You can build and run the dockerfile in docker directory docker build -t waleedhammam/national_id .

Pip installable

  • Library national id is pip installable pip install national-id to be used in the whole system

  • Example usage:

    from lib.national_id import NationalID
    instance = NationalID("28510291201512")
    instance.get_info()
    
    Out:
    (True,
     {'year_of_birth': '1985',
      'month_of_birth': '10',
      'day_of_birth': '29',
      'governorate': 'Al Daqhlia',
      'type': 'Male'})
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

national_id-1.0.3.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

national_id-1.0.3-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file national_id-1.0.3.tar.gz.

File metadata

  • Download URL: national_id-1.0.3.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.5 Linux/5.4.0-52-generic

File hashes

Hashes for national_id-1.0.3.tar.gz
Algorithm Hash digest
SHA256 4049b1609a337032ac248dadef7c48972ebeb98c11317d0adfc65ec4690ee754
MD5 17ccf70370fe6501f424fdf9b9efc758
BLAKE2b-256 2b69523af27b89f978a55b16465f958205c0c71abf83167cbe0c93d6907d8f5d

See more details on using hashes here.

File details

Details for the file national_id-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: national_id-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.5 Linux/5.4.0-52-generic

File hashes

Hashes for national_id-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 318e9dae820f5e6d2eb5fbe76c4ef7e01c5130ff58f9a456e942d098f62b728d
MD5 f91372e9f81b765d88fa16befe3aec85
BLAKE2b-256 f1c7a4ed935e6148f28876f5937571911c7bc210a145ee7c1d3a3aa1f080e846

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page