# New Collection Group APIs
### 1. Create Collection Group
| param | description | type | optional | default | example |
| ------| -----------| ---------| ------| ---------| ----|
| name | Name of the group | str| no | - | Cities |
| description | Description for the group | str| yes | "" | This group contains collections related to cities |
| collections | Collections to be added to group | str/list | yes | [] | ["root-drugs"] |
**GET**
**URL** : https://pre-staging.nferx.com/api/create_collection_group?name=Abnormalities&description=Contains%20all%20collection%20related%20to%20Abnormalities
**POST**
```json
url = 'https://pre-staging.nferx.com/api/create_collection_group'
data = {
"name" : "Abnormalities",
"description" : "Contains all collections related to Abnormalities",
"collections" : ['root-abnormalities-muscular']
}
requests.post(url, data=data, auth=auth)
```
### Response
```json
{
result: "Group Abnormalities created successfully",
success: true
}
```
### 2. Delete Collection Group
| param | description | type | optional | default | example |
| ------| -----------| ---------| ------| ---------| ----|
| names | name of the group | str | no | - | Cities |
**GET**
**URL** : https://pre-staging.nferx.com/api/delete_collection_group?names=Abnormalities
**POST**
```json
url = 'https://pre-staging.nferx.com/api/delete_collection_group'
data = {
"names" : "Cities, Cities_v1" or ['Cities', 'Cities_v2']
}
requests.post(url, data=data, auth=auth)
```
#### Response
```
{
result: "1 groups deleted successfully",
success: true
}
```
### 3. Update Collection Group
| param | description | type | optional | default | example |
| ------| -----------| ---------| ------| ---------| ----|
| name | Name of the group | str| no | - | Cities |
| description | Description for the group | str| yes | "" | This group contains collections related to cities |
| new_name | New name for the group | str | yes | "" | Cities-v1 |
| collections | Collections to be added to group | str/list | yes | [] | ["root-drugs"] |
| action | action to add or remove collections | str | mandatory if collections are given | "" | add/remove |
| id | unique id for group | str | no | "" |
**GET**
**URL** : https://pre-staging.nferx.com/api/update_coll_groups?name=new_group_apis&description=test%20description&collections=root-test-bulk-26&action=remove
**POST**
```json
url = 'https://pre-staging.nferx.com/api/update_coll_groups'
data = {
"name" : "All-Drugs",
"description" : "This group contains collections regarding drugs",
"new_name" : "All-Drugs-v1",
"collections" : ['root-drugs', 'root-companies'],
"action" : "add"
}
requests.post(url, data=data, auth=auth)
```
#### Response
```json
{
result: "Group All_drugs updated successfully",
success: true
}
```
### 4. Get Collection Groups
| param | description | type | optional | default | example |
| ------| -----------| ---------| ------| ---------| ----|
| query | Group to be searched | str | yes | "" | Citi |
| page_num | Page number for pagination | int | yes | 1 | 2 |
| num_results | Number of results per page | int | yes | 100 | 200 |
| order_by | name/count/date | str | yes | collection count | date |
| sort_by | ascending/descending order | str | yes | desc | asc/desc |
**GET**
**URL** : https://pre-staging.nferx.com/api/get_coll_groups
https://pre-staging.nferx.com/api/get_coll_groups?sort_by=asc
**POST**
```json
url = 'https://pre-staging.nferx.com/api/get_coll_groups'
data = {
"query" : "Cities",
"page_num" : 2,
"num_results" : 50,
"sort_by" : "asc",
"order_by" : "date"
}
requests.post(url, data=data, auth=auth)
```
#### Response
```json
{
result: {
count: 8,
total_items: 8,
has_next_page: false,
num_per_page: 8,
groups: [
{
count: 211,
name: "All Drugs",
dt_created: "2019-02-22 07:34:48",
knowledge_synthesis: false,
timeago_date: "4 months ago",
description: ""
},
{
count: 36,
name: "All_Drugs_name_changed",
dt_created: "2019-03-27 11:24:42",
knowledge_synthesis: false,
timeago_date: "3 months ago",
description: ""
},
{
count: 4,
name: "wiki_drugs_by_target_organ",
dt_created: "2018-11-09 06:50:52",
knowledge_synthesis: false,
timeago_date: "8 months ago",
description: ""
},
{
count: 4,
name: "wiki_drugs_by_physiological_function",
dt_created: "2019-06-17 05:08:17",
knowledge_synthesis: false,
timeago_date: "1 month ago",
description: ""
},
{
count: 3,
name: "wiki_drugs_by_mechanism_of_action",
dt_created: "2018-11-09 06:50:52",
knowledge_synthesis: false,
timeago_date: "8 months ago",
description: ""
},
{
count: 3,
name: "drugs",
dt_created: "2019-03-28 10:34:00",
knowledge_synthesis: false,
timeago_date: "3 months ago",
description: ""
},
{
count: 3,
name: "wiki_drugs_by_chemical_classification",
dt_created: "2019-06-17 05:08:17",
knowledge_synthesis: false,
timeago_date: "1 month ago",
description: ""
},
{
count: 2,
name: "FDA Approved Drugs",
dt_created: "2019-06-25 11:58:46",
knowledge_synthesis: false,
timeago_date: "3 weeks ago",
description: ""
}
],
page: 1
},
success: true
}
```
### 5. Get collections for group
| param | description | type | optional | default | example |
| ------| -----------| ---------| ------| ---------| ----|
| group | group name | str | no | - | All Cities |
| query | Collection to be searched | str | yes | "" | Citi |
| page_num | Page number for pagination | int | yes | 1 | 2 |
| num_results | Number of results per page | int | yes | 100 | 200 |
| order_by | name/count/date | str | yes | collection count | date |
| sort_by | ascending/descending order | str | yes | desc | asc/desc |
**GET**
**URL** : https://pre-staging.nferx.com/api/get_collections_for_group?group=sample_testing&page_num=2&num_results=5
**POST**
```json
url = 'https://pre-staging.nferx.com/api/get_collections_for_group'
data = {
"group" : "All-Cities",
"query" : "Capital Cities",
"page_num" : 2,
"num_results" : 50,
"sort_by" : "asc",
"order_by" : "date"
}
requests.post(url, data=data, auth=auth)
```
#### Response
```json
{
result: {
count: 11,
total_items: 11,
has_next_page: false,
num_per_page: 11,
collections: [
{
description: "Coll description for post",
tokens_count: 1,
title: "testing_django_api_sample_2",
dt_created: "2019-07-12 13:16:10",
timeago_date: "5 days ago",
id: "6e36bc1f-testing-django-api-sample-2"
},
{
description: "",
tokens_count: 6,
title: "28june_test_coll1_pavan",
dt_created: "2019-06-28 12:26:32",
timeago_date: "2 weeks ago",
id: "root-28june-test-coll1-pavan"
},
{
description: "New coll description",
tokens_count: 1,
title: "testing_django_api_sample_1",
dt_created: "2019-06-25 11:32:40",
timeago_date: "3 weeks ago",
id: "testing-testing-django-api-sample-1-ombfwuedpg"
},
{
description: "",
tokens_count: 2,
title: "test-kashyap-ovh-1lakh",
dt_created: "2019-06-20 09:22:04",
timeago_date: "4 weeks ago",
id: "kashyap-test-kashyap-ovh-1lakh"
},
{
description: "hema's new collection",
tokens_count: 1,
title: "testing coll new 11111111111",
dt_created: "2019-06-19 07:53:23",
timeago_date: "4 weeks ago",
id: "testing-testing-coll-new-11111111111"
},
{
description: "hema's new collection",
tokens_count: 1,
title: "SyncToTest5June19",
dt_created: "2019-06-19 07:44:36",
timeago_date: "4 weeks ago",
id: "baji-synctotest5june19"
},
{
description: "hema's new collection",
tokens_count: 1,
title: "SyncToTest4June19",
dt_created: "2019-06-19 07:42:35",
timeago_date: "4 weeks ago",
id: "nf-test1-synctotest4june19"
},
{
description: "hema's new collection",
tokens_count: 1,
title: "SyncToTest3June19",
dt_created: "2019-06-19 07:41:49",
timeago_date: "4 weeks ago",
id: "nf-test1-synctotest3june19"
},
{
description: "hema's new collection",
tokens_count: 1,
title: "SyncToTest2June19",
dt_created: "2019-06-19 07:40:45",
timeago_date: "4 weeks ago",
id: "nf-test1-synctotest2june19"
},
{
description: "hema's new collection",
tokens_count: 1,
title: "SyncToTest1June19",
dt_created: "2019-06-19 07:39:47",
timeago_date: "4 weeks ago",
id: "nf-test1-synctotest1june19"
},
{
description: "hema's new collection",
tokens_count: 1,
title: "testing coll new 111111111",
dt_created: "2019-06-19 07:37:58",
timeago_date: "4 weeks ago",
id: "testing-testing-coll-new-111111111"
}
],
page: 1
},
success: true
}
```