The Umbraco Content Api is a package that enables easy integration of Headless Api functionality into your project. The package includes converters for all default Umbraco porperty editors and allows developers to add to and replace them at will.
Out of the box easy to use, full DI support and fast.
- The Umbraco Content Api 2.0.10 works with Umbraco 8.1.3+
- The Umbraco Content Api 3.0.0+ works with Umbraco 8.7.0+
- The Umbraco Content Api 4.0.0+ works with Umbraco 8.14.0+
- The Umbraco Content Api 9.2.0+ works with Umbraco 9.0.0+
- Download the package from NuGet
- Install the package
- Create an UmbracoApiController
- Inject the content resolver
- Resolve the content
[Route("api/content")]
public class ContentApiController : UmbracoApiController
{
private readonly Lazy<IContentResolver> _contentResolver;
private readonly IPublishedContentQuery _publishedContent;
public ContentApiController(
Lazy<IContentResolver> contentResolver, IPublishedContentQuery publishedContent)
{
_contentResolver = contentResolver;
_publishedContent = publishedContent;
}
[HttpGet("{id:guid}")]
public IActionResult Get(Guid id)
{
var content = _publishedContent.Content(id);
return Ok(_contentResolver.Value.ResolveContent(content));
}
}
To create a converter for your custom editor you need to implement the IConverter
interface.
// Converter:
public class SampleConverter : IConverter
{
public string EditorAlias => "My.PropertyEditorAlias";
public object Convert(object value)
{
// If the value is already in a json supported format, just return it.
// Otherwise convert it to a friendly format here.
return value;
}
}
// Composer:
public void Compose(IUmbracoBuilder builder)
{
builder.Converters().Append<SampleConverter>();
}
To replace a converter just add the following to the composer:
builder.Converters()
.Replace<ConverterToReplace, SampleConverter>();
email: admin@contentapi.com password: Password123!
Added options params to all converters.
Added grid editor converters.
Added support for Umbraco MediaPicker 3
Added official support for Umbraco 9
Added default BlocklistConverter. The BlockListConverter will use the default converter if no specific converter is specified for the block's element type.
Migrated to Github Actions for package releases.
Reimplemented Legacy mediapicker