Skip to content

Small API wrapper designed to consume Universities API from Python command line.

License

Notifications You must be signed in to change notification settings

jremes-foss/universities-api-wrapper

Repository files navigation

Universities API Wrapper

Build Downloads

This is a small API wrapper designed to consume Universities API by Hipo. from Python command line. API consumer was built as a project to build first Python library.

Requirements

This package requires requests package to function properly.

Installation

Local installation

Install the package via:

python setup.py install

Docker installation

GitHub repository includes Dockerfile for testing on local box.

Build Docker image with following command:

docker build .

This builds the Docker image. Next, you can run the image in container:

docker exec -it CONTAINER_ID bash

This will land you in a shell in Docker container which allows you to use the library for testing purposes.

PyPI installation

Alternatively, you can install package via PyPI pip package manager.

pip install universities-api-wrapper

Usage

Once installed, you can use wrapper the following way. First, instantiate the library.

from universities_api_wrapper import HipolabsUniversitiesAPI

Then initialize the client. If you are using local connection only:

client = HipolabsUniversitiesAPI("local")

By default, local connector is attempting to connect port 8080/tcp.

Alternatively, if you wish to use remote connection:

client = HipolabsUniversitiesAPI("remote")

If you wish to use alternative port, for example, 8888/tcp, you can invoke connector like this:

client = HipolabsUniversitiesAPI("remote", 8888)

If you pass anything else, library will raise UniversitiesAPIError.

Client has now been initialized. Let's start searching.

Search by Country

client.search("Turkey")

Search by University

client.search(None, "East")

Combination Search

This function is searching by country and university name.

client.search("Turkey", "East")

Filters

You can filter elements of the search results via filter parameter in search function. For example, to return only university names you can use the following:

client.search("Turkey", "Ankara", "names")

To filter websites, use websites filter:

client.search("Turkey", "Ankara", "websites")

To filter domains, use domains filter:

client.search("Turkey", "Ankara", "domains")

Please note: Domain filter will return list which elements are lists.

Unit Tests and Continuous Integration

This module has built-in unit test kit in tests folder. You can run the unit tests by:

python -m pytest tests

This module uses Continuous Integration with GitHub Actions. Pipeline is designed to run automated unit tests as part of Continuous Integration pipeline.

License

This API consumer is licensed under MIT license.