Python API to interact with Uwazi

Overview

Python Uwazi API


Quick Start

To use the API install the requirements

pip3 install -r requirements.txt

and use it like this:

uwazi_adapter = UwaziAdapter(user='admin', password='admin', url='http://localhost:3000')
uwazi_adapter.entities.get_one(shared_id='shared_id', language='en')
uwazi_adapter.files.get_document(shared_id='shared_id', language='en')
uwazi_adapter.settings.get()
uwazi_adapter.templates.get()
uwazi_adapter.thesauris.get()

API

Entities

get_one(shared_id: str, language: str)
get_id(shared_id: str, language: str)
get_shared_ids(to_process_template: str, batch_size: int, unpublished: bool = True)
get(template_id: str, batch_size: int, language: str = 'en', published: bool = False)
get_by_id(entity_id: str)
upload(entity: Dict[str, any], language: str)
delete(share_id:str)

Files

get_document(shared_id: str, language: str)
get_document_by_file_name(file_name: str)
save_document_to_path(shared_id: str, languages: List[str], path: str)
upload_file(pdf_file_path, share_id, language, title)
upload_image(image_binary, title, entity_shared_id, language)
delete_file(id)

Settings

get()
get_languages()

Templates

set(language, template)
get()

Thesauris

get(language: str)
add_value(thesauri_name, thesauri_id, thesauri_values, language)
Comments
  • uploading an entity with a select and multi-select attribute

    uploading an entity with a select and multi-select attribute

    whenever I try to pass a string as the value for a select or multi-select field, I get an error reading: Error uploading entity 422 {"error":"validation failed","validations":[{"keyword":"metadataMatchesTemplateProperties","schemaPath":"#/metadataMatchesTemplateProperties","params":{"keyword":"metadataMatchesTemplateProperties"},"dataPath":".metadata['source']","message":"related dictionary value/s does not exists"

    However, I checked the dictionary for the field, and the value I was trying to upload was present in the dictionary.

    For reference, I was trying to upload an entity of the type "Media Articles" The field in question was "Source" I was trying to upload a "Source" value of "Free Tibet", which is present in the source dictionary according to the "Thesauri" section

    This is how I'm creating the entity:

    entity = {'title': row['title_final'],
                   'template': template_id,
                   'metadata': {
                                'article_contents': [{'value': row['article_final']}],
                                'date_published': [{'value': row['date']}],
                                'date_scrapped': [{'value': row['date_accessed']}],
                                'source': [{'value': 'Free Tibet'}], # gives error
                                'link': [{'value': row['url']}],
                   }
            }
    

    If I comment out the "Source" field, the upload is successful.

    Any advice would be greatly appreciated. Thanks

    @natasha-todi @pddocs

    opened by tanner-ducharme 11
  • posting a template entity

    posting a template entity

    I've managed to establish a connection to our server, but I cannot figure out how to post an entity.

    I want to post a basic entity to a template called 'test'

    The template consists of a title string, a text-body string, and a date. How do I achieve this?

    Thanks

    @natasha-todi @pddocs

    opened by tanner-ducharme 6
  • Error trying to connect to Uwazi with UwaziAdapter()

    Error trying to connect to Uwazi with UwaziAdapter()

    Recently, my code started raising an error when I try to connect to Uwazi with UwaziAdapter().

    As far as I know, nothing in my code was changed between the time when it was functional and when it started failing.

    Also, my uwazi credentials have not been changed.

    The error is as follows:

    Traceback (most recent call last):
      File "post_articles.py", line 307, in <module>
        uploadToUwazi(user, password, template_id, url, df)
      File "post_articles.py", line 143, in uploadToUwazi
        uwazi_adapter = UwaziAdapter(user=user, password=password, url=url)
      File "/Users/Tanner1/Desktop/Projects/RightsActionLab/uwazi/uwazi_api/UwaziAdapter.py", line 14, in __init__
        self.uwazi_request = UwaziRequest(url, user, password)
      File "/Users/Tanner1/Desktop/Projects/RightsActionLab/uwazi/uwazi_api/UwaziRequest.py", line 16, in __init__
        self.connect_sid = self.get_connect_sid()
      File "/Users/Tanner1/Desktop/Projects/RightsActionLab/uwazi/uwazi_api/UwaziRequest.py", line 24, in get_connect_sid
        return response.cookies['connect.sid']
      File "/Users/Tanner1/miniconda3/lib/python3.7/site-packages/requests/cookies.py", line 328, in __getitem__
        return self._find_no_duplicates(name)
      File "/Users/Tanner1/miniconda3/lib/python3.7/site-packages/requests/cookies.py", line 399, in _find_no_duplicates
        raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
    KeyError: "name='connect.sid', domain=None, path=None"
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "post_articles.py", line 314, in <module>
        raise Exception(error)
    Exception: "name='connect.sid', domain=None, path=None"
    

    The only cause I can think of might have something to do with 2-factor authentication. I first noticed the issue right after I set up 2-factor auth on my account

    Any help is greatly appreciated.

    Thanks!

    @natasha-todi @pddocs

    opened by tanner-ducharme 2
  • error upload: maximum field length

    error upload: maximum field length

    When trying to upload an article, I get the following error:

    Error uploading entity 422 
    {"error":"validation failed",
    "validations":
    [{"keyword":"metadataMatchesTemplateProperties",
    "schemaPath":"#/metadataMatchesTemplateProperties",
    "params":{"keyword":"metadataMatchesTemplateProperties"},
    "dataPath":".metadata['article_contents']",
    "message":"maximum field length exceeded"}],
    "prettyMessage":"validation failed",
    "requestId":8694} 
    
    {'title': 'Farewell Letters: A Tribute to the Civil Society Groups, Bloggers, and Media Outlets We Lost in 2021', 
    'template': '5d7fa0edabfb862c766385b3', 
    'metadata': {...}
    

    It appears that the article text is too long. I have two questions related to this issue:

    1. Is there any way around this?
    2. What is the maximum field length for Uwazi?

    Thanks

    @natasha-todi @pddocs

    opened by tanner-ducharme 2
  • Installation error

    Installation error

    when I try to install the repo with: python3 -m pip install git+https://github.com/huridocs/python_uwazi_API.git

    I get the following error: ERROR: git+https://github.com/huridocs/python_uwazi_API.git does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.

    Trying another method, when I try first cloning the repo: git clone https://github.com/huridocs/python_uwazi_API.git

    installing the requirements: cd python_uwazi_API/ && pip3 install -r ./requirements.txt

    and installing the library: pip3 install -e .

    I get a similar error: ERROR: file:///Users/Tanner1/Desktop/Projects/RightsActionLab/uwazi_project/python_uwazi_API does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.

    If someone could please advise on how to proceed it would be greatly appreciated. Thanks!

    opened by tanner-ducharme 2
Owner
HURIDOCS
HURIDOCS equips human rights defenders with tools to mobilise information for justice and accountability.
HURIDOCS
An async python wrapper to interact with the Steam API and its CMs

steam.py A modern, easy to use, and async ready package to interact with the Steam API. Heavily inspired by discord.py and borrowing functionality fro

James Hilton-Balfe 90 Dec 15, 2022
Revolt.py - An async library to interact with the https://revolt.chat api.

Revolt.py An async library to interact with the https://revolt.chat api. This library will be focused on making bots and i will not implement anything

Zomatree 0 Oct 8, 2022
A small bot to interact with the reddit API. Get top viewers and update the sidebar widget.

LiveStream_Reddit_Bot Get top twitch and facebook stream viewers for a game and update the sidebar widget and old reddit sidebar to show your communit

Tristan Wise 1 Nov 21, 2021
This is a small package to interact with the OpenLigaDB API.

OpenLigaDB This is a small package to interact with the OpenLigaDB API. Installation Run the following to install: pip install openligadb Usage from o

null 1 Dec 31, 2021
GitPython is a python library used to interact with Git repositories.

Gitoxide: A peek into the future… I started working on GitPython in 2009, back in the days when Python was 'my thing' and I had great plans with it. O

null 3.8k Jan 3, 2023
Python library to interact with a Z-Wave JS server.

zwave-js-server-python Python library for communicating with zwave-js-server. Goal for this library is to replicate the structure and the events of Z-

Home Assistant Libraries 54 Dec 18, 2022
Autodrive is designed to make it as easy as possible to interact with the Google Drive and Sheets APIs via Python

Autodrive Autodrive is designed to make it as easy as possible to interact with the Google Drive and Sheets APIs via Python. It is especially designed

Chris Larabee 1 Oct 2, 2021
Algofi Python SDK is useful for developers who want to programatically interact with the Algofi lending protocol

algofi-py-sdk Algofi Python SDK Documentation https://algofi-py-sdk.readthedocs.

Algofi 41 Dec 15, 2022
Stop writing scripts to interact with your APIs. Call them as CLIs instead.

Zum Stop writing scripts to interact with your APIs. Call them as CLIs instead. Zum (German word roughly meaning "to the" or "to" depending on the con

Daniel Leal 84 Nov 17, 2022
A library that revolutionizes the way people interact with NextDNS.

NextDNS-API An awesome way to interface with your NextDNS account - via Python! Explore the docs » Report Bug . Request Feature Table Of Contents Abou

null 34 Dec 7, 2022
Interact and easily use Google Chat room webhooks.

Chat Webhooks Easily interact and send messages with Google Chat's webhooks feature. This API is small, but should be a nice framework for working wit

BD103 2 Dec 13, 2021
A telegram bot to interact with a Minecraft Server

telegram-mc-bot A telegram bot to interact with a Minecraft Server It has the following commands: /status - Returns the server status (Online/Offline)

KleynArt 1 Dec 9, 2021
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
alpaca-trade-api-python is a python library for the Alpaca Commission Free Trading API.

alpaca-trade-api-python is a python library for the Alpaca Commission Free Trading API. It allows rapid trading algo development easily, with support for both REST and streaming data interfaces

Alpaca 1.5k Jan 9, 2023
WhatsApp Api Python - This documentation aims to exemplify the use of Moorse Whatsapp API in Python

WhatsApp API Python ChatBot Este repositório contém uma aplicação que se utiliza

Moorse.io 3 Jan 8, 2022
Official python API for Phish.AI public and private API to detect zero-day phishing websites

phish-ai-api Summary Official python API for Phish.AI public and private API to detect zero-day phishing websites How it Works (TLDR) Essentially we h

Phish.AI 168 May 17, 2022
Python API wrapper around Trello's API

A wrapper around the Trello API written in Python. Each Trello object is represented by a corresponding Python object. The attributes of these objects

Richard Kolkovich 904 Jan 2, 2023
A python to scratch API connector. Can fetch data from the API and send it back in cloud variables.

Scratch2py Scratch2py or S2py is a easy to use, versatile tool to communicate with the Scratch API Based of scratchclient by Raihan142857 Installation

null 20 Jun 18, 2022