ouigo


Nameouigo JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/RicardoAlegreMiranda/ouigo
SummaryA module which allows you to retrieve data about the cheapest one-way travels of Ouigo in a date range.
upload_time2024-01-03 14:08:51
maintainer
docs_urlNone
authorRicardo Alegre
requires_python
license
keywords
VCS
bugtrack_url
requirements requests
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Ouigo Python

This module allows you to retrieve the travels in the API of Ouigo, It also serves to filter the best prices and schedules when searching for trains

This is done directly through Ouigo's API, and does not require an API key. All information is obtained by public methods.
# Screenshots
![ouigo_find_travels5](https://github.com/RicardoAlegreMiranda/ouigo/assets/40073353/3290b05c-dccf-4e37-a28e-26d2c605a1af)

![ouigo_find_travels3](https://github.com/RicardoAlegreMiranda/ouigo/assets/40073353/23fb07b1-a700-48fa-b4bf-ad25c7f662e8)

## Installation
Run the following command in the terminal:

```
pip install ouigo
```

## Usage
To create an instance:
```python
from ouigo import Ouigo
"""
It is necessary to indicate in which country you are 
going to carry out the searches (ES = Spain, FR = France)
"""
api = Ouigo(country="ES") 

```
## find_travels
This method searches for all the stations connected to the source station, and returns a list of Train objects with the information of all the trips available for that day at the source station.

From each trip you obtain the data:
- departure_timestamp = The departure time of the train in datetime format
- _u_i_c_station_code: the arrival station code
- name = the name of the departure station
- destination = the name of the arrival station
- outbound the departure date of the trip (string format)
```python
from ouigo import Ouigo

# ES for search in Spain or FR for search in France
API = Ouigo(country="es")  
travels = API.find_travels(origin="Madrid", 
                           outbound="2024-01-21")

for train in travels:
    print(train)
          

"""
console output example: 

Trip(departure_timestamp=datetime.time(18, 15), _u_i_c_station_code='7117000', name='Madrid - Chamartín - Clara Campoamor', price=39.0, destination='Alicante - Terminal', outbound='2024-01-21')
Trip(departure_timestamp=datetime.time(7, 5), _u_i_c_station_code='7160000', name='Madrid - Puerta de Atocha - Almudena Grandes', price=22.0, destination='Barcelona - Sants', outbound='2024-01-21')
...................... etc etc etc
"""
```

You can also filter by indicating:
- destination = Name of the destination or station code (you can consult the json of the stations)
- max_price = filters the maximum price
- maximum_departure_time = data in time format,
- minimum_departure_time = data in time format,
```python


from ouigo import Ouigo
from datetime import time
from ouigo.types_class import Trip

# ES for search in Spain or FR for search in France
API = Ouigo(country="FR")
travels: Trip = API.find_travels(origin="Paris",
                                 outbound="2024-01-21",  
                                 destination="Nantes",
                                 max_price=25,
                                 maximum_departure_time=time(13, 00),
                                 minimum_departure_time=time(7, 00))

for train in travels:
    print(f"price {train.price}, departure time {train.departure_timestamp} ")

"""
Console output example:

price 10.0, departure time 07:11:00 
price 10.0, departure time 07:26:00 
price 16.0, departure time 07:44:00 
"""
```

## get_list_60_days_travels
It is a quick method to find the best prices of the month to a specific destination

Returns a 60-day list of the lowest prices between 2 destinations, it is the same as what happens when enter
        the Ouigo website and display the calendar, it shows the cheapest price of each day

```python
from ouigo import Ouigo

# ES for search in Spain or FR for search in France
API = Ouigo(country="ES")
prices_to_valencia = API.get_list_60_days_travels(outbound="2024-01-15",
                                                  origin="Madrid",
                                                  destination="Valencia")
for prices in prices_to_valencia:
    print(prices)
"""
Console output
Train(date='2024-01-15', price=9.0, is_best_price=True, is_best_price_month=True, Destination='Valencia - Joaquín Sorolla', is_promo=False)
Train(date='2024-01-16', price=9.0, is_best_price=True, is_best_price_month=True, Destination='Valencia - Joaquín Sorolla', is_promo=False)
Train(date='2024-01-17', price=9.0, is_best_price=True, is_best_price_month=True, Destination='Valencia - Joaquín Sorolla', is_promo=False)
Train(date='2024-01-18', price=9.0, is_best_price=True, is_best_price_month=True, Destination='Valencia - Joaquín Sorolla', is_promo=False)
Train(date='2024-01-19', price=15.0, is_best_price=False, is_best_price_month=False, Destination='Valencia - Joaquín Sorolla', is_promo=False)
Train(date='2024-01-20', price=15.0, is_best_price=False, is_best_price_month=False, Destination='Valencia - Joaquín Sorolla', is_promo=False)
Train(date='2024-01-21', price=9.0, is_best_price=True, is_best_price_month=True, Destination='Valencia - Joaquín Sorolla', is_promo=False)
Train(date='2024-01-22', price=13.0, is_best_price=False, is_best_price_month=True, Destination='Valencia - Joaquín Sorolla', is_promo=False)
.....etc etc etc
"""
```

# journal_search
It is a quick method to find all the prices for a specific day and place, it is useful for finding return trips or a quick way to find outward trips.
```python
# ES for search in Spain or FR for search in France
API = Ouigo(country="ES")
prices_to_valencia = API.journal_search(outbound_date="2024-01-15",
                                        origin="Madrid",
                                        destination="Valencia")
for prices in prices_to_valencia:
    print(prices)


"""
Console output:
Trip(departure_timestamp=datetime.time(7, 15), _u_i_c_station_code='7117000', name='Madrid - Chamartín - Clara Campoamor', price=13.0, destination='Valencia - Joaquín Sorolla', outbound='2024-01-15')
Trip(departure_timestamp=datetime.time(11, 15), _u_i_c_station_code='7117000', name='Madrid - Chamartín - Clara Campoamor', price=9.0, destination='Valencia - Joaquín Sorolla', outbound='2024-01-15')
Trip(departure_timestamp=datetime.time(13, 15), _u_i_c_station_code='7117000', name='Madrid - Chamartín - Clara Campoamor', price=9.0, destination='Valencia - Joaquín Sorolla', outbound='2024-01-15')
Trip(departure_timestamp=datetime.time(17, 15), _u_i_c_station_code='7117000', name='Madrid - Chamartín - Clara Campoamor', price=15.0, destination='Valencia - Joaquín Sorolla', outbound='2024-01-15')
Trip(departure_timestamp=datetime.time(20, 15), _u_i_c_station_code='7117000', name='Madrid - Chamartín - Clara Campoamor', price=9.0, destination='Valencia - Joaquín Sorolla', outbound='2024-01-15')
"""
```
[![Coverage Status](https://coveralls.io/repos/github/RicardoAlegreMiranda/ouigo/badge.svg?branch=master)](https://coveralls.io/github/RicardoAlegreMiranda/ouigo?branch=master)

## Disclaimer
> __DISCLAIMER:__ This library is not affiliated, endorsed, or sponsored by Ouigo or any of its affiliates.  
> All trademarks related to Ouigo and its affiliates are owned by the relevant companies.  
> The author(s) of this library assume no responsibility for any consequences resulting from the use of this library.  
> The author(s) of this library also assume no liability for any damages, losses, or expenses that may arise from the use of this library.  
> Any use of this library is entirely at the user's own risk.  
> It is solely the user's responsibility to ensure compliance with Ouigo's terms of use and any applicable laws 
> and regulations.  
> The library is an independent project aimed at providing a convenient way to interact with the Ouigo API, allowing
> individuals to find travels for personal use, and then ultimately purchase them via Ouigo's website.
> While the author(s) will make efforts to ensure the library's functionality, they do not guarantee the accuracy,
> completeness, or timeliness of the information provided.  
> The author(s) do not guarantee the availability or continuity of the library, and updates may not be guaranteed.  
> Support for this library may be provided at the author(s)'s discretion, but it is not guaranteed.  
> Users are encouraged to report any issues or feedback to the author(s) via appropriate channels.  
> By using this library, users acknowledge that they have read, understood, and agreed to the terms of this disclaimer.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/RicardoAlegreMiranda/ouigo",
    "name": "ouigo",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Ricardo Alegre",
    "author_email": "ricardomanuel.alegre@gmail.com",
    "download_url": "",
    "platform": null,
    "description": "# Ouigo Python\r\n\r\nThis module allows you to retrieve the travels in the API of Ouigo, It also serves to filter the best prices and schedules when searching for trains\r\n\r\nThis is done directly through Ouigo's API, and does not require an API key. All information is obtained by public methods.\r\n# Screenshots\r\n![ouigo_find_travels5](https://github.com/RicardoAlegreMiranda/ouigo/assets/40073353/3290b05c-dccf-4e37-a28e-26d2c605a1af)\r\n\r\n![ouigo_find_travels3](https://github.com/RicardoAlegreMiranda/ouigo/assets/40073353/23fb07b1-a700-48fa-b4bf-ad25c7f662e8)\r\n\r\n## Installation\r\nRun the following command in the terminal:\r\n\r\n```\r\npip install ouigo\r\n```\r\n\r\n## Usage\r\nTo create an instance:\r\n```python\r\nfrom ouigo import Ouigo\r\n\"\"\"\r\nIt is necessary to indicate in which country you are \r\ngoing to carry out the searches (ES = Spain, FR = France)\r\n\"\"\"\r\napi = Ouigo(country=\"ES\") \r\n\r\n```\r\n## find_travels\r\nThis method searches for all the stations connected to the source station, and returns a list of Train objects with the information of all the trips available for that day at the source station.\r\n\r\nFrom each trip you obtain the data:\r\n- departure_timestamp = The departure time of the train in datetime format\r\n- _u_i_c_station_code: the arrival station code\r\n- name = the name of the departure station\r\n- destination = the name of the arrival station\r\n- outbound the departure date of the trip (string format)\r\n```python\r\nfrom ouigo import Ouigo\r\n\r\n# ES for search in Spain or FR for search in France\r\nAPI = Ouigo(country=\"es\")  \r\ntravels = API.find_travels(origin=\"Madrid\", \r\n                           outbound=\"2024-01-21\")\r\n\r\nfor train in travels:\r\n    print(train)\r\n          \r\n\r\n\"\"\"\r\nconsole output example: \r\n\r\nTrip(departure_timestamp=datetime.time(18, 15), _u_i_c_station_code='7117000', name='Madrid - Chamart\u00edn - Clara Campoamor', price=39.0, destination='Alicante - Terminal', outbound='2024-01-21')\r\nTrip(departure_timestamp=datetime.time(7, 5), _u_i_c_station_code='7160000', name='Madrid - Puerta de Atocha - Almudena Grandes', price=22.0, destination='Barcelona - Sants', outbound='2024-01-21')\r\n...................... etc etc etc\r\n\"\"\"\r\n```\r\n\r\nYou can also filter by indicating:\r\n- destination = Name of the destination or station code (you can consult the json of the stations)\r\n- max_price = filters the maximum price\r\n- maximum_departure_time = data in time format,\r\n- minimum_departure_time = data in time format,\r\n```python\r\n\r\n\r\nfrom ouigo import Ouigo\r\nfrom datetime import time\r\nfrom ouigo.types_class import Trip\r\n\r\n# ES for search in Spain or FR for search in France\r\nAPI = Ouigo(country=\"FR\")\r\ntravels: Trip = API.find_travels(origin=\"Paris\",\r\n                                 outbound=\"2024-01-21\",  \r\n                                 destination=\"Nantes\",\r\n                                 max_price=25,\r\n                                 maximum_departure_time=time(13, 00),\r\n                                 minimum_departure_time=time(7, 00))\r\n\r\nfor train in travels:\r\n    print(f\"price {train.price}, departure time {train.departure_timestamp} \")\r\n\r\n\"\"\"\r\nConsole output example:\r\n\r\nprice 10.0, departure time 07:11:00 \r\nprice 10.0, departure time 07:26:00 \r\nprice 16.0, departure time 07:44:00 \r\n\"\"\"\r\n```\r\n\r\n## get_list_60_days_travels\r\nIt is a quick method to find the best prices of the month to a specific destination\r\n\r\nReturns a 60-day list of the lowest prices between 2 destinations, it is the same as what happens when enter\r\n        the Ouigo website and display the calendar, it shows the cheapest price of each day\r\n\r\n```python\r\nfrom ouigo import Ouigo\r\n\r\n# ES for search in Spain or FR for search in France\r\nAPI = Ouigo(country=\"ES\")\r\nprices_to_valencia = API.get_list_60_days_travels(outbound=\"2024-01-15\",\r\n                                                  origin=\"Madrid\",\r\n                                                  destination=\"Valencia\")\r\nfor prices in prices_to_valencia:\r\n    print(prices)\r\n\"\"\"\r\nConsole output\r\nTrain(date='2024-01-15', price=9.0, is_best_price=True, is_best_price_month=True, Destination='Valencia - Joaqu\u00edn Sorolla', is_promo=False)\r\nTrain(date='2024-01-16', price=9.0, is_best_price=True, is_best_price_month=True, Destination='Valencia - Joaqu\u00edn Sorolla', is_promo=False)\r\nTrain(date='2024-01-17', price=9.0, is_best_price=True, is_best_price_month=True, Destination='Valencia - Joaqu\u00edn Sorolla', is_promo=False)\r\nTrain(date='2024-01-18', price=9.0, is_best_price=True, is_best_price_month=True, Destination='Valencia - Joaqu\u00edn Sorolla', is_promo=False)\r\nTrain(date='2024-01-19', price=15.0, is_best_price=False, is_best_price_month=False, Destination='Valencia - Joaqu\u00edn Sorolla', is_promo=False)\r\nTrain(date='2024-01-20', price=15.0, is_best_price=False, is_best_price_month=False, Destination='Valencia - Joaqu\u00edn Sorolla', is_promo=False)\r\nTrain(date='2024-01-21', price=9.0, is_best_price=True, is_best_price_month=True, Destination='Valencia - Joaqu\u00edn Sorolla', is_promo=False)\r\nTrain(date='2024-01-22', price=13.0, is_best_price=False, is_best_price_month=True, Destination='Valencia - Joaqu\u00edn Sorolla', is_promo=False)\r\n.....etc etc etc\r\n\"\"\"\r\n```\r\n\r\n# journal_search\r\nIt is a quick method to find all the prices for a specific day and place, it is useful for finding return trips or a quick way to find outward trips.\r\n```python\r\n# ES for search in Spain or FR for search in France\r\nAPI = Ouigo(country=\"ES\")\r\nprices_to_valencia = API.journal_search(outbound_date=\"2024-01-15\",\r\n                                        origin=\"Madrid\",\r\n                                        destination=\"Valencia\")\r\nfor prices in prices_to_valencia:\r\n    print(prices)\r\n\r\n\r\n\"\"\"\r\nConsole output:\r\nTrip(departure_timestamp=datetime.time(7, 15), _u_i_c_station_code='7117000', name='Madrid - Chamart\u00edn - Clara Campoamor', price=13.0, destination='Valencia - Joaqu\u00edn Sorolla', outbound='2024-01-15')\r\nTrip(departure_timestamp=datetime.time(11, 15), _u_i_c_station_code='7117000', name='Madrid - Chamart\u00edn - Clara Campoamor', price=9.0, destination='Valencia - Joaqu\u00edn Sorolla', outbound='2024-01-15')\r\nTrip(departure_timestamp=datetime.time(13, 15), _u_i_c_station_code='7117000', name='Madrid - Chamart\u00edn - Clara Campoamor', price=9.0, destination='Valencia - Joaqu\u00edn Sorolla', outbound='2024-01-15')\r\nTrip(departure_timestamp=datetime.time(17, 15), _u_i_c_station_code='7117000', name='Madrid - Chamart\u00edn - Clara Campoamor', price=15.0, destination='Valencia - Joaqu\u00edn Sorolla', outbound='2024-01-15')\r\nTrip(departure_timestamp=datetime.time(20, 15), _u_i_c_station_code='7117000', name='Madrid - Chamart\u00edn - Clara Campoamor', price=9.0, destination='Valencia - Joaqu\u00edn Sorolla', outbound='2024-01-15')\r\n\"\"\"\r\n```\r\n[![Coverage Status](https://coveralls.io/repos/github/RicardoAlegreMiranda/ouigo/badge.svg?branch=master)](https://coveralls.io/github/RicardoAlegreMiranda/ouigo?branch=master)\r\n\r\n## Disclaimer\r\n> __DISCLAIMER:__ This library is not affiliated, endorsed, or sponsored by Ouigo or any of its affiliates.  \r\n> All trademarks related to Ouigo and its affiliates are owned by the relevant companies.  \r\n> The author(s) of this library assume no responsibility for any consequences resulting from the use of this library.  \r\n> The author(s) of this library also assume no liability for any damages, losses, or expenses that may arise from the use of this library.  \r\n> Any use of this library is entirely at the user's own risk.  \r\n> It is solely the user's responsibility to ensure compliance with Ouigo's terms of use and any applicable laws \r\n> and regulations.  \r\n> The library is an independent project aimed at providing a convenient way to interact with the Ouigo API, allowing\r\n> individuals to find travels for personal use, and then ultimately purchase them via Ouigo's website.\r\n> While the author(s) will make efforts to ensure the library's functionality, they do not guarantee the accuracy,\r\n> completeness, or timeliness of the information provided.  \r\n> The author(s) do not guarantee the availability or continuity of the library, and updates may not be guaranteed.  \r\n> Support for this library may be provided at the author(s)'s discretion, but it is not guaranteed.  \r\n> Users are encouraged to report any issues or feedback to the author(s) via appropriate channels.  \r\n> By using this library, users acknowledge that they have read, understood, and agreed to the terms of this disclaimer.\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A module which allows you to retrieve data about the cheapest one-way travels of Ouigo in a date range.",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/RicardoAlegreMiranda/ouigo"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0f6b07b20d2c849a2d217cfc811e803479471e54b7d5de165e942d8fc021ac9b",
                "md5": "2d4dd628569a7d8a9dcd006b40ce9796",
                "sha256": "f50c756add24d7b74c21c5650669db94bde200d61c2267658e6c119f1016b792"
            },
            "downloads": -1,
            "filename": "ouigo-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2d4dd628569a7d8a9dcd006b40ce9796",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 11219,
            "upload_time": "2024-01-03T14:08:51",
            "upload_time_iso_8601": "2024-01-03T14:08:51.624476Z",
            "url": "https://files.pythonhosted.org/packages/0f/6b/07b20d2c849a2d217cfc811e803479471e54b7d5de165e942d8fc021ac9b/ouigo-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-03 14:08:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "RicardoAlegreMiranda",
    "github_project": "ouigo",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "requests",
            "specs": [
                [
                    "~=",
                    "2.31.0"
                ]
            ]
        }
    ],
    "lcname": "ouigo"
}
        
Elapsed time: 0.17601s