Giter Club home page Giter Club logo

loham's Introduction

Loham

Highly Organized Business Directory API

41k filtered records out of 100k





Test Coverage Supported Python versions


About

Business Directory API built on top of FastAPI and Uvicorn Server uses JWT for authentication and authorization. FastAPI has native support for Uvicorn,Uvicorn is an ASGI server, which means it communicates using the Asynchronous Server Gateway Interface, a modern standard for Python asynchronous applications.

DirectoryLayout

├── .gitignore                     (to preventing unnecessary files from being tracked)           
├── LICENSE                        (for specifying the terms under which the code can be used, modified, and distributed)
├── README.md                      (a github file repository is crucial for providing essential information about your project)
├──
├── requirements.txt               ( For keeping all the library name wich project is using)
├── app
│   │
│   ├── __init__.py                 ( Initializing the package from here.)
│   ├── companies.db                (A SQLite database file for storing all information related to companies)
│   ├── main.py			    (The main Python script for running the application)
|   |                  
│   ├── company                     (A directory containing code related to company management)
│   │   └── __init__.py
|   |   |── database.py  	    (Python code for interacting with the SQLite database)
|   |   |── models.py               (Python code defining data models for companies)
|   |   |── oauth2.py  		    (Python code for OAuth2 authentication)
|   |   |── schemas.py              (Python code defining Pydantic schemas for data validation)
|   |   |── token.py                (Python code for generating authentication tokens)
│   │   └─── routes                 (A directory containing API routes for company-related operations)
│   │          └── __init__.py   
|   |          |── auth.py          (Python code defining authentication routes)
|   |          └── comp.py          (Python code defining CRUD operations for companies)
|   |          └── users.py         (Python code defining CRUD operations for users)
|___|                            


Basic structure

To see the version

import requests
import json

req = requests.get('https://loham.onrender.com/v1/about')
data_str = req.content.decode('utf-8')
json_data = json.loads(data_str)

print(json.dumps(json_data, indent=4))	    
curl -X 'GET' \
  'https://loham.onrender.com/v1/about' \
  -H 'accept: application/json'

output

{
    "Version": "0.0.1",
    "Developer": "Abdisa (Netkas) | (0_0)",
    "Released Year": "April 10 2024",
    "Github": "https://github.com/abdimk/loham"
}

Get category count

import requests
import json

req = requests.get('https://loham.onrender.com/get_category_count')
data_str = req.content.decode('utf-8')
json_data = json.loads(data_str)

print(json.dumps(json_data, indent=4))

output

    [
{
        "categories": "Foreign Suppliers to Ethiopia",
        "category_count": 49
    },
    {
        "categories": "Hotels and Restaurants, Tour and Travel",
        "category_count": 64
    },
    {
        "categories": "Insurance Brokerage",
        "category_count": 18
    },
    {
        "categories": "Micro and Small Enterprises in Ethiopia",
        "category_count": 3931
    }
]

Get Company with db id

import requests
import json

id = 609
req = requests.get(f'https://loham.onrender.com/get/{id}')
data_str = req.content.decode('utf-8')
json_data = json.loads(data_str)

print(json.dumps(json_data, indent=4))

output

The output is based of the specified schema in fastAPI(response schema)

{
    "id": 609,
    "company_name": "CAROGA PHARMA ETHIOPIA PLC",
    "phone_number": "+25 11 4161090/4165159/4654944",
    "mobile": "+251 91 1209007",
    "fax": "+251 11 4654595",
    "sub_city": "Kirkos",
    "business_type": "Private",
    "location": "Addis Ababa, Ethiopia",
    "url": "https://www.2merkato.com/directory/709-caroga-pharma-ethiopia-plc",
    "primary_category": "None",
    "categories": "Commission Agent"
}

Get companies with initals in thier name

import requests
import json


#common key initals are like agro,pharma,agents,consultancy,export,import

key = 'export'  # for example to get companies that have pharma in their name
req = requests.get(f"https://loham.onrender.com/get_with_initals/{key}")
data_str = req.content.decode('utf-8')
json_data = json.loads(data_str)

print(json.dumps(json_data, indent=4))

output

"returns a list of arryays max 10 for free users"

[
    {
        "id": 57,
        "company_name": "GIGAR TRADING IMPORT, EXPORT & DISTRIBUTOR",
        "phone_number": "+251 11 5518267/5505853/54",
        "mobile": "+251 91 1201117",
        "fax": "+251 11 5502911",
        "sub_city": "",
        "business_type": "Private",
        "location": "Addis Ababa",
        "url": "https://www.2merkato.com/directory/11267-gigar-trading-import-export-distributor",
        "primary_category": "None",
        "categories": "Commercial Agent"
    },
    {
        "id": 68,
        "company_name": "Tsegaab Teklu Import Export PLC",
        "phone_number": "+251-11-6525213",
        "mobile": "",
        "fax": "",
        "sub_city": "Kirkos",
        "business_type": "",
        "location": "Tsegaab Teklu Import Export PLC: Import and Export. Kirkos Sub-City Addis Ababa Region 14 15963 City: Addis Ababa Administrative region: Addis Ababa Country: Ethiopia, Addis Ababa, Ethiopia",
        "url": "https://www.2merkato.com/directory/16504-tsegaab-teklu-import-export-plc",
        "primary_category": "None",
        "categories": "Commercial Agent"
    }
]

Get with initals with post request

import requests
import json


url = 'https://loham.onrender.com/get_with_initals'

# payload = {
#     "company_name": "string", # Optional
#     "sub_city": "string", #Optional
#     "business_type": "string",  #Optional
#     "primary_category": "string", #Optional
#     "categories": "string" #Optional
#   }

payload = {
    "sub_city": "yeka",
    "business_type": "private",
    "categories": "Ethiopian Importers"
    }

req = requests.post(url, json=payload)
data_str = req.content.decode('utf')
json_data = json.loads(data_str)

print(json.dumps(json_data, indent=4))

output

list of arrays max 10 results

[
    {
        "id": 3511,
        "company_name": "Sisay Gulema Building Material General Importer",
        "phone_number": "+251 115 15 58 11",
        "mobile": "+251 911 21 21 16",
        "fax": "+251 115 15 21 24",
        "sub_city": "yeka",
        "business_type": "Private",
        "location": "Urael, Besides Ministry of Agriculture and Urban Development, Addis Ababa, Ethiopia",
        "url": "https://www.2merkato.com/directory/14864-sisay-gulema-building-material-general-importer",
        "primary_category": "Pipes and Fittings/polypopylene",
        "categories": "Ethiopian Importers"
    },
    {
        "id": 3540,
        "company_name": "Dagem Kennedy General Trading PLC",
        "phone_number": "",
        "mobile": "+251 930 11 03 26, +251 911 62 67 84, +251 930 11 03 25",
        "fax": "",
        "sub_city": "Yeka",
        "business_type": "Private",
        "location": "22 Mazoria, Behind H&M Building, House #1006, Addis Ababa, Ethiopia",
        "url": "https://www.2merkato.com/directory/19748-dagem-kennedy-general-trading-plc",
        "primary_category": "Electrical Materials/Equipments",
        "categories": "Ethiopian Importers"
    }
]

Get(search) with phone number

import requests
import json

url = 'https://loham.onrender.com/get_with_phone'

payload = {
    "phone_number": "251116",
    "limit": 10 # the no of results you want to get
    }

req = requests.post(url, json=payload)
data_str = req.content.decode('utf')
json_data = json.loads(data_str)

print(json.dumps(json_data, indent=4))
    returns an array of list companies type

Credits and Contibution


Special Thanks to

Tiangolo for creating FastAPI


Any type of suggestions, pointing out bug or contribution is highly appreciated :).

loham's People

Contributors

abdimk avatar

Stargazers

Mark avatar  avatar DGCP3 avatar Besufikad Micheal avatar Fraol Lemecha avatar  avatar KJ avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.