semvec/pypi-packages huggingface dataset:
pyeti-python 1.0
Revival version of pyeti, the API for Yeti Threat Intel Platform.
License: Apache
Requires Python: >=3.6
Keywords: yeti threat intel api

# pyeti
Python bindings for Yeti's API

## Installation

`$ python3 setup.py install` should get you started. After this gets a little more maturity.

Or install via pip `$ pip3 install pyetix` 

## Testing

You can run tests from the root directory by running:

    $ pip3 install nose
    $ python3 setup.py test
    
**Note that most tests require a full running install of Yeti on localhost:5000**

## Some examples

First thing is to import the library and instantiate a client.

```python
import pyetix, json    # json is only used for pretty printing in the examples below 
api = pyetix.YetiApi("http://localhost:5000/api/")
```

If you are using a self signed cert on your yeti instance you can set the `verify_ssl` parameter to `True` to false to ignore warnings.
Otherwise all ssl connections are verified by default.

```python
import pyetix, json    # json is only used for pretty printing in the examples below 
api = pyetix.YetiApi("http://localhost:5000/api/", verify_ssl=False)
```


### Adding observables

```python
results = api.observable_add("google.com", ['google'])
print(json.dumps(results, indent=4, sort_keys=True))
```
### Bulk add

```python
results = api.observable_bulk_add(["google.com", "bing.com", "yahoo.com"])
print(len(results))
3
print(json.dumps(results[1], indent=4, sort_keys=True))
```

### Get a single observable

```python
results = api.observable_add("google.com")
print(results['id'])
info = api.observable_details(results['id'])
print(json.dumps(info, indent=4, sort_keys=True))
```

### Search for observables

```python
api.observable_add("search-domain.com")
result = api.observable_search(value="search-dom[a-z]+", regex=True)
print(json.dumps(result, indent=4, sort_keys=True))
```

### Add observables
```python
result = api.observable_file_add("/tmp/hello.txt", tags=['benign'])
print(json.dumps(result, indent=4, sort_keys=True))
# Get file contents
api.observable_file_contents(objectid="594fff86bf365e6270f8914b")
'Hello!\n'
api.observable_file_contents(filehash="e134ced312b3511d88943d57ccd70c83") # you can also use any hash computed above
'Hello!\n'
```