Livelihoods Explorer

LivelihoodActivitySummary

The LivelihoodActivitySummary endpoint allows you to filter Livelihood Zones by the contribution of livelihood activities towards a wealth group’s total income.

Example

This URL will produce a list of zones where sorghum crop production accounts for at least 20% of the calories for a wealth group.

http://livelihoods.fews.net/api/livelihoodactivitysummary/?language=en&slice_by_product=R0114&slice_by_strategy_type=CropProduction&min_kcals_consumed_percent=20

Filters

There are two categories of filter needed on this endpoint.

  • Standard filters: These filter the Baselines that are returned. The standard
    filter parameters determine Livelihood Activities that are included in the data to be aggregated.

  • Slice filters: Slice filters do not remove Baselines from the results by themselves; they only filter the statistics. The slice parameters are used to calculate the amount of overall income, expenditure, kcals_consumed, and percentage_kcals that are derived from the slice.

Each row in the results contains the total amount for each indicator (income, expenditure, kcals_consumed, percentage_kcals), the amount contributed by the slice, and the percentage of the total contributed by the slice.

Because the results are aggregated across the requested fields, it is very easy to over count the values. It is important to understand exactly what data is being aggregated and ensure that appropriate filters have been applied. For example, if a Baseline contains data for both the Baseline and the Response scenario, and you don't specify a scenario filter, then the resulting indicator values will be the sum of the values for both scenarios.

Standard filters

There are a number of standard filters available for this endpoint.

View a list of standard filters and their accepted values.

Filter

Accepted values

country

Use a full country name such as Mali.

livelihood_zone

Use a Livelihood Zone code such as ML12.

scenario

Baseline

Response

wealth_group_category

B/O (better off)

M (middle)

M-L (middle-lower)

M-U (middle-upper)

P (poor)

P-F (poor female headed)

P-IDP (poor IDPs)

VP (very poor)

VP-IDP (very poor IDPs)

strategy_type

MilkProduction

ButterProduction

MeatProduction

LivestockSale

CropProduction

FoodPurchase

PaymentInKind

ReliefGiftOther

Hunting

Fishing

WildFoodGathering

OtherCashIncome

OtherPurchase

product

Use a product code such as R01122.

quantity_produced

Float (numerical value that can contain a decimal point)

quantity_sold (Quantity Sold and/or Exchanged)

Float

quantity_other_uses

Float

quantity_consumed

Float

price

Float

income

Float

expenditure

Float

kcals_consumed

Integer

percentage_kcals (Percentage of required kcals)

Float

Slice filters

The slice parameters are:

  • slice_by_product: These match any CPC code that starts with the value. For multiple, repeat the parameter, eg, slice_by_product=R0&slice_by_product=B01. The product hierarchy can be retrieved from the classified product endpoint /api/classifiedproduct/.

  • slice_by_strategy_type: You can specify multiple. Use the strategy_type codes listed above. These are case-insensitive but otherwise must be an exact match.

The API currently only supports a single slice at a time and will create a single slice by combining all slice parameters. If both product and strategy type are included then the slice selects Livelihood Activities that match both. If you pass a slice_by_product for a Product that isn't relevant for the selected slice_by_strategy_type then no activities will be selected and the slice values will be zero.

The aggregates produced are:

  • income_sum_row

  • expenditure_sum_row

  • kcals_consumed_sum_row

  • percentage_kcals_sum_row

  • total_income_as_percentage_kcals_row

If a slice is specified, the following additional aggregates are produced:

  • income_sum_slice

  • income_sum_slice_percentage_of_row

  • expenditure_sum_slice

  • expenditure_sum_slice_percentage_of_row

  • kcals_consumed_sum_slice

  • kcals_consumed_sum_slice_percentage_of_row

  • percentage_kcals_sum_slice

  • percentage_kcals_sum_slice_percentage_of_row

  • total_income_as_percentage_kcals_slice

  • total_income_as_percentage_kcals_slice_percentage_of_row

Note that total income is kcals income plus cash income.

You can filter by any calculated slice or row aggregate by prefixing its name with min_ or max_. For example, &min_income_sum_slice_percentage_of_row=52.

Fields

You select the fields you want to view by using the fields parameter in the usual way.

If you omit the fields parameter all fields are returned. Using fields=simple with this endpoint will only return aggregate fields.

View a list of available fields.
  • Aggregations as listed above

  • country

  • source_organization_name

  • livelihood_zone

  • livelihood_zone_baseline_name

  • reference_year_start_date

  • reference_year_end_date

  • valid_from_date

  • valid_to_date

  • main_livelihood_category

  • livelihood_zone_baseline_description

  • wealth_group_category

  • wealth_group_category_name

  • wealth_group_category_ordering

  • percentage_of_households

  • average_household_size

  • currency

  • population_source

  • population_estimate

  • product

  • product_common_name

  • season_name

  • season_ordering

  • additional_identifier

  • strategy_type

  • scenario

  • id

  • season

  • livelihood_strategy

  • wealth_group

  • livelihood_zone_baseline

  • source_organization

  • iso3166a2 (2 letter country code)

The fields parameter determines how data is aggregated and reported in the results. If a field is included, then rows will be disaggregated to show figures broken down by that field. Any fields not included are aggregated together.

Because slice_percentage_of_row shows the percentage of the total row value contributed by the slice, if the slice field (product and/or strategy type) is also in the &fields parameter, then the slice_percentage_of_row values will be either 0 or 100%, depending on whether the field value in this row matches the slice.

Example

In the example above, a slice_by_product filter is included.

In the first set of results, where product is not included as a field, the kcals_consumed_sum_slice_percentage_of_row values include 88 and 15.

In the second set of results, where product is included as a field, the kcals_consumed_sum_slice_percentage_of_row values are all either 100 or 0.

Language

Translated fields (e.g. name, description) are rendered in the currently selected locale if possible. These can be set using &language= (e.g. &language=pt). Country is an exception as it has different translations that follow ISO standards.

Language options include:

  • ar (Arabic)

  • en (English, default)

  • es (Spanish)

  • fr (French)

  • pt (Portuguese)

Ordering

This endpoint uses the standard ordering parameter. If none are specified, the results are sorted by the aggregations descending (i.e., biggest percentage first).

View a list of ordering options.
  • country

  • source_organization_name

  • livelihood_zone

  • liveihood_zone_baseline_name

  • reference_year_start_date

  • reference_year_end_date

  • valid_from_date

  • valid_to_date

  • main_livelihood_category

  • livelihood_zone_baseline_description

  • wealth_group_category

  • wealth_group_category_name

  • wealth_group_category_ordering

  • percentage_of_households

  • average_household_size

  • currency

  • population_source

  • population_estimate

  • product

  • product_common_name

  • strategy_type

  • scenario

  • id

  • livelihood_strategy

  • wealth_group

  • livelihood_zone_baseline

  • source_organization

  • iso3166a2