Skip to content

FvD/junr

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
R
 
 
 
 
 
 
man
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

junr

Travis-CI Build Status Coverage Status CRAN Status Badge

Access Open Data in R through the Junar API

The Junar API is the basis for a number of Open Data initiatives in Latin America and the USA. The junr package is a wrapper to make it easier to access data made public through the Junar API. Some examples of implementations are: the City of Pasadena, and the City of San Jose. Others are listed on the Junar website.

Installation

install.packages("devtools")
devtools::install_github("FvD/junr")

Usage

For a full example, please consult the package vignette.

Load the package and set URL and API-Key

library(junr)
base_url <- "http://api.datosabiertos.presidencia.go.cr/api/v2/datastreams/"
api_key <- "the-API-Key-from-the-corresponding-url" 

With this connection information the junr package helps you to do the following:

Get the index of data behind the base URL

get_index(base_url, api_key)

You can also just get a list of GUID’s list_guid(base_url, api_key) or a list of data set titles list_titles(base_url, api_key).

Get a particular data set

data_guid <- "COMPR-PUBLI-DEL-MINIS"
purchasing_data <- get_data(base_url, api_key, data_guid)

Determine data dimensions

get_dimensions(base_url, api_key)

Clean up currency data

currency_data <- get_data(base_url, api_key, "LICIT-ADJUD-POR-LOS-MINIS")
currency_data$`Monto Adjudicado` <- clean_currency(currency_data$`Monto Adjudicado`)  

Accede Datos a través del API de Junar en R

El API de Junar es la base para varias iniciativas de Datos Abiertos en Latino América y los EEUU. El paquete junr facilita el acceso a estos datos des R. El objetivo es fomentar el uso de los datos disponibles haciendo el acceso lo mas fácil. Algunos ejemplos de implementaciones son: el Portal de Datos Abiertos del Gobierno de Costa Rica y la Ciudad de Córdoba (Argentina) entre otros. Otros se pueden encontrar en el sitio web de Junar.

Instalación

Para instalar este paquete desde Github es necesario tener el paquete devtools instalado:

install.packages("devtools")
devtools::install_github("FvD/junr")

Uso

Para un ejemplo completo por favor consulta la documentación.

Carga el paquete y define el URL y API-Key

library(junr)
url_base <- "http://api.datosabiertos.presidencia.go.cr/api/v2/datastreams/"
api_key <- "El-API-Key-que-obtuviste-de-la-pagina"

Obten un indice de los datos detras del URL

get_index(url_base, api_key)

Para tener solo una lista de los GUID la instrucción puedes usar list_guid(url_base, api_key) o para solo un listado de los títulos: list_titles(url_base, api_key)

Obten un conjunto de datos determinado

guid_datos <- "COMPR-PUBLI-DEL-MINIS"
datos_compras <- get_data(url_base, api_key, guid_datos)

Determina la cantidad de datos disponibles

get_dimensions(url_base, api_key)

Limpiar valores de divisas

datos_con_divisas <- get_data(base_url, api_key, "LICIT-ADJUD-POR-LOS-MINIS")
datos_con_divisas$`Monto Adjudicado` <- clean_currency(datos_con_divisas$`Monto Adjudicado`)